Recently I noticed that cron was sending mail on my Ubuntu server. I needed to figure out how to stop it from sending mail. There are two ways ..to do this. Here is how:
The first way to stop Cron from sending mail involves setting cron so that it doesn’t send mail for all of your cron jobs. To do this, open up the crontab editor with the cron job command, crontab -e. Then above all the other cron job listings, add the line MAILTO=”” Here is an example of the beginning of my crontab file:
#
MAILTO=””
#
50 12 * * * /etc/RotateRsyncLogs.sh
This will configure cron to not send mail at all. Sometimes however you want cron to send mail, but have a specific job to not send mail. In order to do this, just add this to the end of your cron command:
/dev/nul 2>&1
For example:
30 * * * * /etc/runthis.sh >/dev/nul 2>&1
This will redirect the output of the cron job to /dev/nul
This article was originally posted on www.mikestechblog.com Any reproduction on any other site is prohibited and a violation of copyright laws.