I‘m using a CentOS Linux server. How do I run a cron job every minute? How can I use crontab to execute script or shell command every minute?
The basic syntax is as follows to run crontab job every minute:
* * * * * /path/to/script[donotprint][/donotprint]
* * * * * /path/to/command
OR run script:
* * * * * /scripts/lxc/update www1 db1 memecache1
OR ping our nas server every minute:
* * * * * /sbin/ping -q -c 4 nas01.sxi.io >/dev/null
The crontab file syntax is as follows:
* * * * * /command/to/be/executed - - - - - | | | | | | | | | ----- Day of week (0 - 7) (Sunday=0 or 7) | | | ------- Month (1 - 12) | | --------- Day of month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)
The asterisk (*) operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to every hour or an asterisk in the month field would be equivalent to every month. In this specific examples, an asterisk in all fields means run job every minute. See our cron jobs tutorials for more information.