Testing cron Jobs

  • Post author:
  • Post category:How To

1. Use crontab -e when possible when editing your cron table. It validates the entries on save.

2. Redirect output to a log file. For example:

 * * * * *  /path/script.sh &> /path/script.log    

3. Run your script manually under the same user used in crontab.

4. If you are using run-parts (cron.daily, cron.hourly, etc), you can manually run run-parts.

run-parts /etc/cron.daily    

5. If you are not using run-parts and putting cron jobs directly in crontab, you can change the cron schedule. For example, instead of running the job daily, run it every minute for testing purposes.

6. Monitor the cron log file. Here is tailing the log in CentOS.

tail -f /var/log/cron    

7. Here are many possible reasons why crontab does not work.