When the Linux crond runs a scheduled job, it typically sends an email to root when the job is complete. It uses the MAILTO variable that is set in /etc/crontab to determine who receives this mail. By default this is set to "root", so the local root account will receive all mail from cron.

There are several ways to stop this behavior. Here we will discuss a few possible solutions.

Change the MAILTO variable to blank

You can edit the /etc/crontab file and change the MAILTO variable to blank. Open /etc/crontab in your favorite editor and change the line that reads:

MAILTO=root

to look like this:

MAILTO=""

This will effectively disable email from crond as it will be configured to have no email address.

This method is not preferred as it would also disable any error messages that you might want to see. If one of the cron jobs exits with an error code, you may never know about it.

Disable all mail for crond

You can simply disable the mail feature in crond. To do this you have to edit the /etc/sysconfig/crond file and change the CRONDARGS (crond arguments) string from this:

CRONDARGS=

To this:

CRONDARGS=-m off

Keep reading for more options.

Redirect Standard Output (STDOUT) and Standard Error (STDERR) to null to suppress output.

By suppressing all output of a script, there will be nothing for crond to send.

Add the following code to the end of any /etc/crontab entry to send stdout and stderr to the bit bucket (/dev/null).

>/dev/null 2>&1

Here is what a script may look like when done correctly:

0 5 * * * /example/script >/dev/null 2>&1

This also has the same drawbacks as above. Since you are redirecting both STDOUT and STDERR, you may never know of any errors that occur.

Of course you have the option of only sending STDOUT to /dev/null, so any errors will still be sent.

0 5 * * * /example/script > /dev/null

This will allow you to still get emails if there are errors. This can also cause problems if your scripts complete their task but don't complete correctly.

To learn more about Standard Stream (stdin, stdout, stderr) see Introduction to Linux IO, Standard Streams, and Redirection.

Configure crond to Send the Script Output to the system log, and disable sending email of output.

You can configure crond to send all output to the system log and disable email (like above). This is probably the a good option because if anything goes wrong with your cron jobs, you have logs of the output and the errors. To do this we have to edit the /etc/sysconfig/crontab file and change the CRONDARGS line to this:

CRONDARGS=-s -m off

Conclusion

All of the above methods work, some are more ideal than others. I figured I would present you with some common options and let you decide what is best for your configuration.

Resources