LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   shutup cron.hourly mail reports (https://www.linuxquestions.org/questions/linux-software-2/shutup-cron-hourly-mail-reports-337310/)

darkleaf 06-26-2005 10:20 AM

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!

Satriani 06-26-2005 11:06 AM

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

darkleaf 06-26-2005 11:32 AM

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.

Satriani 06-27-2005 09:44 AM

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


darkleaf 06-27-2005 10:28 AM

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!


All times are GMT -5. The time now is 12:00 PM.