How can I only receive emails from cron if there are errors?In the overwhelmingly vast majority of cases, the tasks will run just fine - and I truly do not care about the output.It is only in the rare case of a failure that I want/need to know.I have procmail available - but am not sure if what I'm describing is possible to manage externally to cron correctly.
Disable cron emails unless there are errors?
cron;email;error handling
As you are not caring for the output, you can redirect the STDOUT of a job to /dev/null and let the STDERR being send via mail (using MAILTO environment variable).So, for example:......MAILTO=foobar@example.com......* * * * * /my/script.sh >/dev/nullwill send mail when there is output only on STDERR (with the STDERR), and will discard the STDOUT.This of course assumes that when a program has written on STDERR, has failed; this might not be always the case. If you have control over the program, you can make it do so. For any complex case, you should write a wrapper of some kind that runs the command(s) and send mail accordingly. And put the wrapper as the cron job.