Feb 11, 2009

How do I to disable the mail alert send by crontab?

Q. How do I to disable the mail alert send by crontab? When my job is executed and the jobs cannot run normally it will sent an email to root. Why do I receive e-mails to my root account from cron? How can I prevent this?

A. crontab command is use to maintain crontab files for individual users.

By default the output of a command or a script (if any produced), will be email to your local email account. To stop receiving email output from crontab you need to append following string:

Cron Job Prevent the sending of errors and output

To prevent the sending of errors and output, add any one of the following at the end of the line for each cron job to redirect output to /dev/null.
>/dev/null 2>&1.
OR
&> /dev/null

1 comment:

irado said...

you can simply put a line in your crontab header, like this:

MAILTO=""
###
[commands after this comment line..]

note some Linux distributions wants "" after the equal signal, other wants it simply with bald line (MAILTO=) instead.

Welcome to Non-geek's
Linux Handbook!

or if you will, Linux Cookbook.

Read my READY-TO-USE
RECIPE-LIKE
tutorials on Linux applications~

Subscribe if you are willing to follow.

If you find the post useful, please click the donate button on the upper right corner. Any amount is useful.