6

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?

2 Answers 2

14

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.

2
  • 3
    The second solution is much better, because that way you are still notified of any problems in crontab scripts.
    – sleske
    Jul 16, 2009 at 14:23
  • 5
    >> will append data of stdout to file. It cannot be used to redirect stderr. Use 2> to redirect stderr. Jul 16, 2009 at 14:43
5

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

<command> > /dev/null 2>&1 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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