/ tech-note

Your cron job is not running? Check out the followings!

Your cron scheduler should be working as long as you put your files to /etc/cron.hourly or something. If not, the problem might be found somewhere like the following:

  • Is the permission correct? It should be 755 or something like that.

  • Does your filename use only upper and lower cases, hyphens, and underscores? The cron is pretty pedantic about the filename. Do NOT add a file extension!

  • How about the result of run-parts --test /etc/cron.hourly? Is your script found there?

  • If you use crontab (not /etc/cron.hourly), did you set your scheduler correctly to crontab? Specifically correct user, correct time, and in Ubuntu, did you destroy your error log? Here are examples:

    • Run every hour?

        0 * * * * python /var/www/your_script >/dev/null 2>&1 
    • Run every 3 hours?

        0 */3 * * * python /var/www/your_script > /dev/null 2>&1
  • Does your script destroy your error log via >/dev/null 2>&1? If not, either change your script so that it doesn't output any logs, or change your scheduler so that it doesn't output any logs.

Still not working? Here is how to debug.
  • Check out log files by grep CRON /var/log/syslog

  • The execution time and user are described in /etc/crontab. To edit it, run crontab -e.
    WARNING: The result on cat /etc/crontab and crontab -e is different as the former is about root.