Turn of "stdout" Messages in Cron

Since I started frequent cron backups with [CRIBBS][a_110616113305] my unix mailbox (`/var/mail/user`) has been filling up with `stdout` (output) and `stderr` (error) messages kindly left there courtesy of cron. While being informed about what my cron jobs (and the script they’re running) have managed to do while I was gone is great, I really only need to know when there is a problem.

Searching the googlewebs for an answer leads you to all kinds of I/O redirecting resources and sites telling you how to stop both `stdout` and `stderr` from being delivered to your *nix mail. Most seem to miss the obvious–you want to know about the errors but can do without the general output.

The answer is pretty simple (thanks to this [I/O redirect resource][a_110616114319]). If your crontab entry looks like this:

00 12 * * * sh ~/some_script.sh

… then all you need to do is add `1>/dev/null` to the end of the line, like this:

00 12 * * * sh ~/some_script.sh 1>/dev/null

This will effectively redirect “1” (`stdout`) to /dev/null (a non existent designation). All other error messages (`stderr`) will still be delivered as per usual.

[a_110616113305]: http://adam.merrifield.ca/2011/05/27/backups-with-cribbs/
[a_110616114319]: http://tldp.org/LDP/abs/html/io-redirection.html

 

Adam Merrifield

 

Leave a Reply