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

I have a little problem with the cron daemon. I want to stop it from sending mail for a specific command. For example if I have:

10 * * * * someScript1.sh
15 * * * * someScript2.sh

I want to get the mail from someScript1 but not from someScript2. I tried setting the MAILTO="" but that just blocks everything.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Redirect all output to a back hole

10 * * * * someScript1.sh
15 * * * * someScript2.sh > /dev/null 2>&1

See http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/ for more information.

share|improve this answer
    
One little question... doesn't that send the output of the script to null but still sending mail? –  zozo Apr 4 '11 at 9:02
    
No, that sends all output of someScript2.sh to /dev/null. –  tex Apr 4 '11 at 9:06
1  
@zozo: cron sends the output, if any, by mail. Redirecting both stdout and stderr to /dev/null, means there is no output to mail. –  MattBianco Apr 4 '11 at 9:14
add comment

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.