PDA

View Full Version : Reciece e-mail when running cronjob



Cyberboy
08-17-2005, 01:52 AM
Hello,

Everytime when a cronjob is running, I will recieve an e-mail with the details. Beceause there are running 100 cronjobs every hour, I recieve 100 e-mails every hour.

Is there a possibility to configure this?

Thanks in advance,
Rick

nobaloney
08-17-2005, 04:01 PM
Cronjobs mail the job output to the user running the cronjob.

To keep it from happening, call the job with a redirect to redirect all output to /dev/null.

For example, if you were going to send a directory listing to yourself from a cronjob you might call:

ls

To keep the output from being sent to the user running the job you'd call:

ls > /dev/null

This would still send you any errors. If you don't want the errors you'd try something like this:

ls > /dev/null 2>&1

Jeff

Cyberboy
08-22-2005, 09:02 AM
It works great, thanks a lot!

nobaloney
08-22-2005, 04:28 PM
You can use this creatively... for example you can pipe the output to a file, then grep the file, and only send you an email if something in the file is set; we do this to send us copies of "/dev/mdstat" only if one of our RAIDs is broken.

Jeff

Cyberboy
08-24-2005, 08:16 AM
Isn't that just the same as using "> /dev/null" in a cron?

nobaloney
08-24-2005, 01:02 PM
What I meant was instead of piping it to /dev/null you could pipe it to a file, then run another script to manage the file and do something with it based on the contents.

Jeff

Cyberboy
08-24-2005, 02:40 PM
Okay, I thought I didn't understand it ;) Thanks a lot!