Debug Cron

Table of Contents

Suddenly Cron wasn’t running my mail script; I verified that the script itself was still working, so than I began the venture into the unknown: how to debug Cron?

Serverfault has a good answer. Everything seemed to checkout, and I verified that it was working to write to a tmp file. The file was being written.

Finally, by removing the line that smothers output to /dev/null I was able to find the problem: the need for an absolute path name (as evidently the Cron user couldn’t run getmail without a full path). I’m not sure what had changed, but this fixed it.

  1. Verify the script called by the crontab was working (find it with crontab -e)
  2. Verify that cron is otherwise working by having it write to a file echo "cron runs!" /tmp/file
  3. Ensure that any > /dev/null is gone from the called script, causing Cron to send all resulting text to the owner

Doing this revealed that cron was failing to find one of the required programs. Once I knew this, I knew to simply change my script to have the absolute path to the script: /usr/local/bin/getmail rather than just getmail. Then all was good!

Tory Anderson avatar
Tory Anderson
Full-time Web App Engineer, Digital Humanist, Researcher, Computer Psychologist