Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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)

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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