Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Prevent cron.daily script output 1

Status
Not open for further replies.

nerbonne

Technical User
Dec 11, 2006
99
US
I have multiple scripts in the /etc/cron.daily/ directory on server running Redhat. Each day I get an email with the output of the scripts, but I do not wish to get this email. How can I turn it off? Since these scripts are in the daily directory, they are not actually in the crontab so I cannot simply add 2>&1>/dev/null
 
You can tell logwatch what you want to do with file. Usually it is sent to root. You can just have it sent to a trash bucket if you want.
 
Hmm, I've looked in the script and it runs another file which is written in machine language. I don't see anywhere to change where the email is sent. Here is what I get every day:

--------------

/etc/cron.daily/logrotate:

Shutting down kernel logger: [ OK ]
Shutting down system logger: [ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]

------ Contents of /etc/cron.daily/logrotate:

#!/bin/sh
export TMPDIR=/var/spool/logrotate/tmp

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0


------------- Contents of /etc/logrotate.conf:

daily
rotate 7
create
compress
include /etc/logrotate.d
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 4
}


 
Sorry nerbonne, For some reason I was thinking your were getting the email that logwatch sends every morning. I had just finished reading mine before coming here and must have had it on the brain. You can create a user who's job it is to collect unwanted mail and edit /etc/crontab and send the mail to that user instead of root. This however, is not the best way of dealing with this issue. When logrotate comes across a bad line or command, it will produce a message very much like the one you get. I think the problem is with logrotate and not cron.daily itself.

 
Well the message is from logrotate. I was wondering how you read my mind because in my first post I did not mention logrotate.

I did not realize that scripts in cron.daily were run by /etc/crontab. I just piped the output from cron.daily to /dev/null and that should fix it. I don't care to get the output of logwatch but I do want other root emails.
 
That's what I do with my crap that I don't want to see... Just go into my script in cron.whatever where it executes the routine and add the > /dev/null after it and never see it again. If I have a problem with something I can just take it back off and get the mail a few days to look at it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top