LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 01-24-2012, 09:27 AM   #1
buee
Member
 
Registered: May 2009
Posts: 81

Rep: Reputation: 16
Question 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.
 
Old 01-24-2012, 09:58 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6
Posts: 1,449

Rep: Reputation: 438Reputation: 438Reputation: 438Reputation: 438Reputation: 438
Did you even bother to google it?

http://www.cyberciti.biz/faq/disable...ontab-command/
 
Old 01-24-2012, 10:01 AM   #3
MartinStrec
Member
 
Registered: Jan 2012
Location: Czech
Distribution: Fedora, RHEL, Ubuntu, Mint
Posts: 110

Rep: Reputation: 13
Edit '/etc/crontab'

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
 
Old 01-24-2012, 10:11 AM   #4
buee
Member
 
Registered: May 2009
Posts: 81

Original Poster
Rep: Reputation: 16
@TenTenths:
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"
 
Old 01-24-2012, 10:16 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6
Posts: 1,449

Rep: Reputation: 438Reputation: 438Reputation: 438Reputation: 438Reputation: 438
Quote:
Originally Posted by buee View Post
@TenTenths:
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
Sorry for my sharp response, I'm tired and forgot my first rule of never post when tired. On the example from google and Martin the MAILTO variable is your friend in this particular case. I make extensive use of it and then use other methods such as having any cron script I use do its own logging or sending of e-mail alerts.
 
Old 01-24-2012, 10:20 AM   #6
MartinStrec
Member
 
Registered: Jan 2012
Location: Czech
Distribution: Fedora, RHEL, Ubuntu, Mint
Posts: 110

Rep: Reputation: 13
Also you can modify argument for crond

edit /etc/sysconfig/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). )
 
Old 01-25-2012, 05:54 AM   #7
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 11.4
Posts: 1,319

Rep: Reputation: 252Reputation: 252Reputation: 252
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.
 
Old 10-01-2012, 02:27 PM   #8
ranamalo
LQ Newbie
 
Registered: Oct 2012
Posts: 2

Rep: Reputation: Disabled
Solution

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
CRONDARGS='-m off'

And restart crond

# /etc/init.d/crond restart
 
  


Reply

Tags
cron, email


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Cron Error: Cron <EMAIL> /tmp/.X11-unix/.bash/update >/dev/null 2>&1 (failed) willrocks Linux - Server 8 01-20-2012 12:08 AM
How to stop root sending email to a private address bstafford51 Linux - Server 3 11-04-2010 12:54 PM
Stop sending me email j.todd LQ Suggestions & Feedback 3 10-07-2008 04:53 PM
sending an email to a email address after a perl operation meluser Programming 9 04-07-2003 01:26 PM


All times are GMT -5. The time now is 09:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration