Where are cron errors logged?
If I setup cron
jobs incorrectly they appear to silently fail. Where can i go to check an error log?
As others have pointed out, cron
will email you the output of any program it runs (if there is any output). There are basically three possible solutions if you don't get anything
crond
could not even start a shell for running the program or sending emailcrond
had troubles mailing the output, or the mail was lost.- the program did not produce any output (including error messages)
Case 1. is very unlikely, but something should have been written in the cron logs. Cron has an own reserved syslog facility, so you should have a look into /etc/syslog.conf
(or the equivalent file in your distro) to see where messages of facility cron
are sent. Popular destinations include /var/log/cron
, /var/log/messages
and /var/log/syslog
.
In case 2., you should inspect the mailer daemon logs: messages from the Cron daemon usually appear as from root@yourhost
. You can use a MAILTO=...
line in the crontab file to have cron send email to a specific address, which should make it easier to grep the mailer daemon logs. For instance.
MAILTO=my.offsite.email@example.org
00 15 * * * echo "Just testing if crond sends email"
In case 3., you can test if the program was actually run by appending another command whose effect you can easily check: for instance,
00 15 * * * /a/command; touch /tmp/a_command_has_run
so you can check if crond
has actually run something by looking at
the mtime of /tmp/a_command_has_run
.