Plainnotes

Where cron output goes

2025-04-23 · 2 min readTools

A cron job fails and nobody hears about it. cron mails stdout and stderr to the job owner, and most machines have no MTA, so the mail goes nowhere.

Either log from the job:

*/5 * * * * /usr/local/bin/job.sh >> /var/log/job.log 2>&1

or wrap it and alert on failure:

*/5 * * * * /usr/local/bin/job.sh 2>&1 | logger -t job || curl -fsS https://hooks.example/alert

|| only sees the last command's status, so set -o pipefail is needed for the pipeline to be trustworthy.

If you really want mail, install msmtp or ssmtp with a relay and set MAILTO= at the top of the crontab. For small projects a webhook is less work.