Ubuntu – Why does the cron job run every 1 minute although I set it every 1 hour

cron

I set my cron job via crontab -e, with the following code:

* */1 * * * python /var/www/your_script >/dev/null 2>&1

I didn't add .py extension as it makes the cron job invalid.

However, after logging it by grep CRON /var/log/syslog, the script is executed every one minute, not every one hour.

Mar  1 07:40:01 my-instance CRON[4471]: (me) CMD (python /var/www/your_script >/dev/null 2>&1)
Mar  1 07:41:01 my-instance CRON[4474]: (me) CMD (python /var/www/your_script >/dev/null 2>&1)
Mar  1 07:42:01 my-instance CRON[4477]: (me) CMD (python /var/www/your_script >/dev/null 2>&1)

Why does my script start to be run every one minute, not every one hour? My environment is Ubuntu 16.04.

Best Answer

If you want to set cronjob for every hour, you can do it any of following way:

You can run:

0 * * * * /path/to/script

which reads

On minute 0, each hour, each day of month, each month, each day of the week.

or

@hourly /path/to/script

or

0 */1 * * * /path/to/script

An asterisk (*) can be used so that every instance (every hour, every weekday, every month, etc.) of a time period is used.

Reference: crontab, CronHowto

Related Question