Topic: Disable email alerts in crontab (Read 4422 times)
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 5642
45485 credits Members referred : 3
« on: Dec 23, 2006, 02:56:08 pm »
Today I checked my mail server and realized that there are thousands of bounced emails that were statistics regarding the crontab.
Crontab regularly will send one email for each crontab entry which will contain all the output from the command that executed.
But as most of those are useless, and in case that you don't recieve this email adress, it can cause some problems to the mail server, so here is a simple solution to get over it. First open your crontab entries by typing this command in console :
Code:
crontab -e
Then edit each and every record - that you don't want to recieve email - and append this : > /dev/null 2>&1
What if we want to send the email to some other email id? say, instead of the default admin ID, i want to send the cron output to soem other secondary email id ! What to do in that case?
The answer is this, but I am not sure if it actually works as I haven't tested :
Code:
00 6 * * * root rdate -s time.nist.gov | mail -s "Subject of mail" user@host.tld
Replace user@host.tld with the email address that you want to receive the mail and you are done