LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 06-26-2005, 10:20 AM   #1
darkleaf
Senior Member
 
Registered: Jun 2004
Location: the Netherlands
Distribution: debian SID
Posts: 2,170

Rep: Reputation: 45
shutup cron.hourly mail reports


I recently put a script in there and now cron spams me every hour with reports I don't want and I don't need (it's simply setting time against a server so I notice as soon as it's off ). I went into /etc/crontab and deleted the --report from the line for cron.hourly. This didn't stop it though.

Now I found this site http://www.unixgeeks.org/security/ne...ix/cron-1.html saying:
Quote:
Output from cron

As I've said before, the output from cron gets mailed to the owner of the
process, or the person specified in the MAILTO variable, but what if you
don't want that? If you want to mail the output to someone else, you can
just pipe the output to the command mail.
e.g.

cmd | mail -s "Subject of mail" user

If you wish to mail the output to someone not located on the machine, in the
above example, substitute user for the email address of the person who
wishes to receive the output.

If you have a command that is run often, and you don't want to be emailed
the output every time, you can redirect the output to a log file (or
/dev/null, if you really don't want the output).
e,g

cmd >> log.file
Where would I change those things or how do I shut cron up or make it write to a log file. Which file do I have to edit to do these things as I can't figure out from this text where to do that.

Thanks for the help!
 
Old 06-26-2005, 11:06 AM   #2
Satriani
Member
 
Registered: Mar 2003
Location: The Netherlands
Distribution: Red Hat 7.3, Red Hat 9, Solaris8, Slackware 10, Slax on USB, AIX, FreeBSD, WinXP, AIX, Ubuntu
Posts: 418

Rep: Reputation: 30
When putting it into the /etc/cron.hourly directory as a script, you might want to set the output of you command to /dev/null:
Code:
#!/bin/sh
/path/to/script >> /dev/null
if you used the crontab -e:
You add the >> /dev/null right after the command you have put in the crontab
ie. if you added

30 * * * * /path/to/script >> /dev/null

it would run the script every hour on *.30hrs and the output is sent to /dev/null

Last edited by Satriani; 06-26-2005 at 11:07 AM.
 
Old 06-26-2005, 11:32 AM   #3
darkleaf
Senior Member
 
Registered: Jun 2004
Location: the Netherlands
Distribution: debian SID
Posts: 2,170

Original Poster
Rep: Reputation: 45
I directly put this into the directory:

Quote:
#! /bin/sh

dpkg-reconfigure ntpdate
So would it become this then:

Quote:
#! /bin/sh

dpkg-reconfigure ntpdate >> /dev/null
Or do I have to put this script elsewhere and call it in the file in the cron.hourly directory.
 
Old 06-27-2005, 09:44 AM   #4
Satriani
Member
 
Registered: Mar 2003
Location: The Netherlands
Distribution: Red Hat 7.3, Red Hat 9, Solaris8, Slackware 10, Slax on USB, AIX, FreeBSD, WinXP, AIX, Ubuntu
Posts: 418

Rep: Reputation: 30
You are correct with your second statement... That should do the trick...
You could also do something else, that in case an error occurs you will get a message..
then your command would be:
Code:
#! /bin/sh
dpkg-reconfigure ntpdate 2>&1 1>/dev/null
This causes error-messages to go to stdout, and stdout to go to /dev/null
Since stderr (2) was defined before stdout (1) was, it will actually go to stdout and not to /dev/null

If this is too confusing, just use:
Code:
#! /bin/sh
dpkg-reconfigure ntpdate >/dev/null
 
Old 06-27-2005, 10:28 AM   #5
darkleaf
Senior Member
 
Registered: Jun 2004
Location: the Netherlands
Distribution: debian SID
Posts: 2,170

Original Poster
Rep: Reputation: 45
I have a bit of programming experience though I wouldn't have come up with that myself I get the idea

It worked great for my script. Apparently there's something else spitting errors. O well searching for that thing now. Thanks for the help!
 
  


Reply


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
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
Stopping the hourly mail to root Phaethar Linux - General 2 09-16-2005 02:25 PM
No More Cron Mail, Cron Error? Xhost Linux - General 3 07-26-2004 04:28 PM
cron.hourly question Raw Kuts Linux - Newbie 1 08-18-2003 12:34 PM
How do I run/write an hourly cron? KoopaTroopa Linux - Newbie 1 08-16-2003 06:12 PM


All times are GMT -5. The time now is 04:58 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