I just need to know:
- Our systems are set up to use /var/log/cron to store cron logs, however, there are no exit codes stored here just start/stop times and the PID of the jobs. How can I force our servers to just log a simple exit code for the cron job?
Note: I’m not trying to force the script that is being called to report its own exit code I just wanted to see if it was possible that Cron itself could log is own exit status. Almost if you were able to do an echo $? right after it ran to see what the code was.
2
Answers
you should be able to get the return value by referring to
$?
– a users crontab (which is not allowed to write to/root/no-no
) it looks like this:then see the output of logger in this case.
I think you are lookin for,
This will notify you when exit code is not equal to 0 or when cron job will fail.