Disable cron job eMails

Exim Mail Throughput (With Cron)

So I have been playing around with a new project, part of the project requires a cron to run every 30min that will basically overwrites some files and a mysql database to a pre packaged default configuration; the shell scripts is fairly basic I will probably go more into that in another post after the syntax is cleaned up a bit more.

Once I setup the cron about a day later I noticed by local Exim mail server was seeing an eMail come through, as you can see from the graph above, the times matched perfectly with the cron running so I was fairly sure this had something to do with it. If you want to get some similar graphs for your server check out this post I did a few days ago.

So i started by checking the local mail output:

cat /var/mail/mail

Sure enough I saw the cron job output filling up that file, so all I needed to do was get the cron deamon to forget about this output as I wasn’t really too bothered about it, first open up your crontab:

crontab -e

Next you just need to append the following to your cron task line.

>/dev/null 2>&1

So it looks something like this.

0/30 * * * *	/test/restore.sh >/dev/null 2>&1

Then close the crontab and restart the service, and that should be it, all of the cron output will just be send to the null device that will effectively just bin it without creating an eMail.

/etc/init.d/crond restart

Technology enthusiastic with many ongoing online projects one of which is this personal blog PingBin.
While also working full time within a data center designing and maintaining the network infrastructure.

Leave a reply:

Your email address will not be published.