[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: crontab $MAILTO question



DvB wrote:

Alec <alec1976nyc@yahoo.com> writes:

(...)

Can I configure cron to mail me
a) *only* when there were errors
b) email only STDERR (not STDOUT)
(...)

I assume you're asking about some type of special cron functionality
which e-mails automatically... however, I would probably do this with a
script... i.e.



In Alec's case I'd perhaps try a quick-and-dirty solution like adding this to a file in the /etc/cron.d directory:

# Run queue every day at 04:30
30 04 * * *  root  backup-script >log-out 2>log-err || cat log-err

I haven't tried this, but the redirections should send program output on stdout and stderr to their respective logfiles thus avoiding any mail from cron, and the "cat" part should output the error log on stdout only if errors occur, which would then be mailed by cron to the MAILTO address.

--
Carlos Sousa



Reply to: