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:
which reads
or
or
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