Stop Cron from sending email
I have a CentOS based e-mail sever that runs a bunch of cron jobs. The problem I'm having is that cron is sending emails as logs and that seems to be cluttering things up. The e-mails are entering loops between the server itself and the Barracuda SPAM filter that we have, then it times out. Each e-mail loop causes ~15 log entries and each cron job runs every 5 minutes 24x7. The math isn't important, but it's a ridiculous amount of logging. I would like to stop cron from sending email completely, but can't find it. I would like to have cron output to just a local log file if possible.
Did you even bother to google it?
set MAILTO variable to empty
MAILTO="" or MAILTO=
Probably a better way is to edit the script that is responsible for sending the mails, e.g. /etc/cron.hourly/a-script
and there redirect the output of error messages to the null device
/path/to/command -parameters >/dev/null 2>&1
Yes, I did, and I followed a link to a similar answer. I guess my question should've been "How do you universally disable cron from sending email?" rather than disabling emailing for particular cron jobs
@MartinStrec: Basically, see above. I followed your methods, but I'm looking for a universal way of telling cron "just don't send e-mail" or "output to file rather than email"
Also you can modify argument for crond
(I guess it is the same in your distribution)
and use CRONDARGS variable to set what ever you want
see 'man crond' manpage for all arguments
I guess you expect CRONDARGS="-s"
( -s This option will direct Cron to send the job output to the system log using syslog(3). )
It would indeed be an option to set it in the configuration file, but it depends whether you have the original vixie-cron where itís not available AFAICS, or cronie. man cron should reveal it.
Background info that may help people:
CentOS 6 runs cronie
CentOS 5 runs vixie-cron
In CentOS6 cron's default behavior is to send an email to the owner of the cron job if the cron job produces any output (stdout or stderr). If the flag: MAILTO is present and has a value (in crontab or elsewhere /etc/cron.d for example) any output will be emailed the the email specified after MAILTO.
To turn off emailing use the flag -m off in /etc/sysconfig/crond:
# Settings for the CRON daemon.
# CRONDARGS= : any extra command-line startup arguments for crond
And restart crond
# /etc/init.d/crond restart
|All times are GMT -5. The time now is 03:58 PM.|