Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I stop cron from emailing me the results of jobs I schedule?

share|improve this question
add comment

3 Answers

up vote 12 down vote accepted

By setting the environment variable "MAILTO" as ""

Somethig like:

SHELL=/bin/bash
MAILTO=



01 * * * *  /your/path/to/script/here.sh
share|improve this answer
add comment

If you want a single job to stop email you simply append >/dev/null 2>&1 to it

For example:

0 * * * * /home/script >/dev/null 2>&1
share|improve this answer
1  
If you are sure that one run will finish before the next starts, it can be worth redirecting the output to a named file rather than to /dev/null: that does give the option of checking what happened to the last run if you suspect a problem. –  mas Jul 18 '09 at 19:02
add comment

Cron only emails you if there is output, either on stdout or stderr.

If it's script you've written, make it less verbose - remove unnecessary echo or print statements. Redirecting stdout to /dev/null is also a valid solution:

2 * * * * /my/script > /dev/null

If you still get messages after doing that, then the output is on stderr, thus it should be an error, which you should resolve.. If not, you can redirect stderr to /dev/null with..

2 * * * * /my/script > /dev/null 2> /dev/null

..although disregarding error messages is generally a bad idea! (How will you know when the cron job is broken?)

You could redirect a specific command's output from stderr to stdout using 2>&1 - for example:

command_which_prints_messages_to_stderr 2>&1 # redirect stderr to stdout

..then direct stdout to /dev/null in your cron job - that way you silence the loud command, without losing error messages

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.