8
2
I have several cron jobs that run (in /etc/cron.daily
, /etc/cron.hourly
, /etc/cron.weekly
, etc.) and email root@localhost
with the results. I'd like to stop those emails if the jobs are succeeding, and only email on error (which I understand can be done by redirecting stdout
to /dev/null
). I understand how to do that for individual cron jobs, but the scripts in those special directories are run using run-parts
. What is the best way to suppress success emails for those scripts?
Wouldn't that suppress the error emails too (because they wouldn't produce any output)? Also, I need to do this for my
cron.XXX
directories which userun-parts
, so it's not as simple as redirecting for individual scripts. – jrdioko – 2011-05-29T01:47:20.143No the idea is that
stderr
is thrown away thenstderr
is redirected tostdout
. I'm not sure whatrun-parts
is, but however it works redirection ofstdout
and thenstderr
seems to be the way. – pavium – 2011-05-29T02:01:50.637Aha, I googled
run-parts
. That does complicate the issue, doesn't it. Maybe you should avoidrun-parts
and invoke each script separately. – pavium – 2011-05-29T02:05:21.960Ah ok, I understand.
run-parts
runs all scripts in directories like/etc/cron.daily
, so the trick is passing along the redirection to the individual scripts it is running. – jrdioko – 2011-05-29T02:06:30.150I think so. I couldn't find anything about redirecting all output from
run-parts
(not even in theman
page I just discovered I have. – pavium – 2011-05-29T02:14:37.9802Are you sure about the
>/dev/null 2>&1
bit? I tested it and that funnels everything to/dev/null
, where if you drop the2>&1
only stdout gets removed. – jrdioko – 2011-05-29T04:42:53.813