LinuxMoz

Linux Stuff && Coffee

Disable Crontab Mail

| Comments

Fed up with your mail box getting blasted with automated Crontab mail, follow this tutorial to disable crontab mail and help reduce the clutter in your mailbox.

Disable Crontab Mail

Crontab Mail Default Settings

By default crontab will send the output of any commands or scripts it runs to your email address. To prevent this action you need to redirect the script or command output to /dev/null

Disable Crontab Mail (Option 1)

To prevent cron from emailing you the script output we need to redirect the the output to /dev/null by adding the following to the end of your crontab script or command:

1
2
3
4
5
&> /dev/null

An example of a crontab script with the output redirected to /dev/null (to disable crontab email):

0 2 4 * * /usr/local/blah-script.sh &> /dev/null

Disable Crontab Mail via the MAILTO variable (Option 2)

Another method to disable cron from emailing is to set a blank value for the MAILTO variable, to do this open your crontab with:

1
crontab -e

Add the following to the top of the file:

1
MAILTO=""

Save the file, you’re done… The crontab editor is Vi by default on most Linux / Unix systems, please see our tutorial for help with Vi Commands.

Comments