Disable mail alert by CRON

Normally, we had seen that after the crontab executes your cron job it sends you a email as a notification on root email.

I don’t want the email to be send on root account.

Here is how you can do this:

METHOD #1 – 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

Example – 1:

40 16 * * * /bin/echo "this will not be emailed to root"  > /dev/null 2>&1

Example – 2:

40 16 * * * /bin/echo "this will not be emailed to root"  &> /dev/null

So when this command will be executed by cron, NO email will be send on root account.

METHOD #2 – Disable mail by using MAILTO variable.

Just when you do crontab -e for editing your cron jobs. Add

MAILTO=" "

as your first line in the crontab file.

Enjoy.

God Bless.

Advertisements