If I setup cron jobs incorrectly they appear to silently fail. Where should I look for an error log to understand what went wrong?
|
|
||||
|
|
|
As others have pointed out,
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 In case 2., you should inspect the mailer daemon logs: messages from the Cron daemon usually appear as from
In case 3., you can test if the program was actually run by appending another command whose effect you can easily check: for instance,
so you can check if |
|||||
|
|
The default cron configuration will send you a mail with the output of your program. If this fails, you could try wrapping your failing program in a shell script that ensures that the program does not fail, and you could further log the output. This is a configurable setting on some cron implementations. |
|||
|
|
|
You can always explicitly send the job output to a log file:
Keep in mind that this will supercede the mail behaviour that has been mentioned before, because crond iself won't receive any output from the job. If you want to keep that behaviour you should look into tee(1). |
|||
|
|
|
Cron logs basic info to |
||||
|
|
|
You should get email from
at the command prompt.
Note that unless you have configured your system as an Internet email server, this mail subsystem is used only within the machine. You can send email to and receive from other users on the machine, but you may not be able to send email out to the world, and email from the outer world certainly won't be able to come to your machine. |
|||
|
|
|
If you aren't seeing the mails, or if you are spamming root@yourcompany with the errors, try sending the output to Syslog instead:
Then, wait for the cronjob to run and look for the error in /var/log/messages (or /var/log/user.log on some systems). This works great for errors messages which are only 1-2 lines long, such as "yourcronjob: command not found". It also makes use of your existing syslog infrastructure (Logrotation, central syslogging, Splunk, etc.) It also reduces email spam to root. It may not be a good solution if your cronjob generates hundreds of lines of output. |
||||
|
|
|
I use In my Edit
I just Google'd |
|||
|
|