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.

By default, crontab on, for example, Debian, will mail any output of a job in your crontab to that user. How would one go about disabling this functionality?

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

There are two main ways of doing this, as I discovered.

Either you set the MAILTO-variable to nothing at the start of the file:

MAILTO=""

or you redirect each cronjobs output to /dev/null:

<command> > /dev/null

The second having the advantage that output on stderr should still be mailed to you.

share|improve this answer
    
If you want to also redirect stderr on a command by command basis just add '>> /dev/null' to the end of the second line. –  Catherine MacInnes Jul 16 '09 at 14:15
1  
The second solution is much better, because that way you are still notified of any problems in crontab scripts. –  sleske Jul 16 '09 at 14:23
4  
>> will append data of stdout to file. It cannot be used to redirect stderr. Use 2> to redirect stderr. –  Saurabh Barjatiya Jul 16 '09 at 14:43
add comment

To prevent output of both stdout and stderr use the following syntax:

<command> > /dev/null 2>&1
share|improve this answer
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.