Managing cron and similar E-Mails from headless systems

W Scott Lockwood III vladinator at gmail.com
Fri Feb 17 15:23:10 UTC 2017


On Fri, Feb 17, 2017 at 7:35 AM, Chris Green <cl at isbd.net> wrote:

> No it doesn't.  There will only be an E-Mail from cron when there's
> something send to stdout or stderr.  Those rsync commands are silent
> unless there's an error.  That's the beauty of the default setup, cron
> works silently unless something goes wrong.
>

This is fundamentally the wrong approach. Not every command you're going to
run can run silently. A far better way to do this is to use a construct
like  &> /dev/null


> >    A wrapper script is no different, except you can further refine it by
> >    adding logic to also handle sending email only if there is an error.
> >    cron does not do this at all. Yes, you are going to have to write
> code.
>
I'd prefer to do it once though (in E-Mail or other configuration)
> rather than every time I create a cron job.
>

Wow. The basic script to do this is dirt simple, and can be recycled as
many times as you need. Seriously, this is not hard. In the script, check
for a non-zero exit. On a non-zero exit, mail yourself whatever you want it
to tell you.

--
W. Stacy Lockwood III
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20170217/8e6216cc/attachment.html>


More information about the ubuntu-users mailing list