I've read a few posts on the web, gone and looked for the file they are mentioning and haven't found it. I'm in Ubuntu 11 and trying to troubleshoot a cron job that isn't running, even though I have it sent to run every 3 minutes. The command in the cron job runs with no errors.
Where does cron store the history of what jobs were run and when? How do I make sure it's enabled?
2 Answers
Cron puts the output of the executed script into an e-mail (use the mail command to read them) or they go to the system logs.
A cron job usually doesn't run because of a huge amount of assumption. Assuming that something runs right when you (YOU as the user) run it, is a good way to make mistakes.
Typical mistakes are missing rights or invalid path. You should test your script:
- if you can start it as the user of the cron job without environment variables
- if you can start it anywhere in the file-system (you should use full paths, not relative ones)
When testing user rights don't use su - <user> but su <user> as the former will initialize the environment from .bashrc which you won't have by default when cron runs.
I'm pretty sure the standard cron doesn't keep a log. Apparently you can cause it to log by adding a cron.debug /var/log/cron entry to /etc/syslog.conf then send syslogd a HUP signal.
Usually, failed jobs result in email to the relevant user.
A common cause of cron job failure is programs that rely on environment variables or paths that are set during interactive login but not by cron.
2