Last Updated: February 25, 2016
· geetotes

Troubleshooting Cron Jobs

If you see a log of your cron job running in var/log/cron (using CentOS in this example), but you can tell that the script isn't running, if could be due to one of two issues:

  • Your crontab file is not properly terminated and you need to add a newline to the end of the crontab.

  • You're missing essential PATHs in your script. This happens often when you've patched together a script from your bash history.

For example:

cd /var/www/mywebsite && rake generate

won't work because the PATH for rake is not set. This happens even if the job is running as a user with the proper path variable set in their .bashrc or .bash_profle. You need to manually add the PATH variable into the script, ala:

cd /var/www/mywebsite && rake generate

for it to work.