Suppressing Cron Job Email Notifications

Detailed instructions on how to suppress email notifications from Linux Cron jobs.

Recently I found myself being tormented by email notifications from one of my servers that was running a PHP script via a Cron job every ten minutes. Even though the script was running successfully, I was getting an email every ten minutes containing the output of the script. So how do we suppress these emails? You have a number of options.

Using the MAILTO variable

The MAILTO variable allows you to set the email address that the notification emails from Cron are sent to. You can suppress all emails from your Cron jobs by setting this to an empty string like so:

$ crontab -e

Now on the top of the file, add:

MAILTO=""

Then save and close the file.

Sending output to /dev/null

The /dev/null location in Linux is a "black hole" for data: any output sent here is gone, which makes it a great candidate for suppressing output from Cron jobs.

To suppress all output (STDOUT and STDERR) from your Cron job, append > /dev/null 2>&1 to the end of your job:

$ crontab -e

Example:

*/30 * * * * command  > /dev/null 2>&1

The number 2 represents the STDERR (standard error) stream, while 1 is the STDOUT (standard out) stream.

If you want to receive emails about errors only but not successes, append > /dev/null to your job to suppress output from STDOUT only:

*/30 * * * * command > /dev/null

John Collins

I have been writing about web technology and software development since 2001. I am the developer of the Alpha Framework for PHP, and the five.today personal productivity app. I love open source, technology, and economics.