I have a list of cronjobs where some executes daily and others execute very 15 minutes. I do want to receive an email for the ones executed daily, but wants email disabled for the ones executing every 15 minutes(or maybe receive a daily email), is there a way to do this in crontab?

link|improve this question

72% accept rate
feedback

1 Answer

up vote 5 down vote accepted

To stop the output from being e-Mailed for a specific cron entry, redirect the output for those cron to /dev/null. Suffix your cron entry with this to redirect both STDOUT and STDERR:

> /dev/null 2>&1

While you can redirect different types of output different ways, for more advanced handling such as digests, you will need to script it.

As a side note, important notifications shouldn't be e-Mailed. Use central logging (syslog) or monitoring. (nagios)

link|improve this answer
3  
To script a digest just change > /dev/null 2>&1 to >> /var/log/{filename} 2>>&1 and add a cron entry to send and truncate that file on a schedule. – Chris Nava May 26 '10 at 19:37
1  
Good idea on that. Really, just cat would be enough as a cron entry. – Warner May 26 '10 at 19:41
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.