Linux – Disable mail notification in crontab

Disable mail notification in crontab

When I use a crontab to schedule a smart script with embedded mail notification function, it’s annoying to have a notification sent by cron process (a stupid notification with no interesting information). I will explain you how to disable mail notification in crontab.

I – Disable mail notification in crontab

By default cron process always send mail notification, it’s possible to disable mail notification for one cron job. You just need to redirect the default stdout to /dev/null.


root@cron:~# crontab -e
30 * * * * /opt/firewall.sh > /dev/null 2>&1

An another way exists, but its global, its apply to all schedules tasks. You disable mail notification, just define no mail address on the option MAILTO.


root@cron:~# crontab -e
MAILTO=""

II – Crontab Manual

http://www.linux-france.org/article/man-fr/man5/crontab-5.html

florian

Hi, I'm Florian and I'm 32 years old. I have discover IT at 17, and i had my first internet connection at 23. So i'm not going to say that i was very precocious in this domain... PS : I 'm French, so please, be lenient with my english ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.