Hi all, I have a cron script that runs every - calls a program that analyse logs and crate graphs with the info. The way I set it up is simply to make a script that call the program, and stick it in the /etc/cron.hourly directory. Now I get a mail every hour. How do I get it not to send the mail? I know how to do this from the crontab file, but not if I use the cron.xyz directories directly. Thanks -- Kind regards Hans du Plooy Newington Consulting Services hansdp at newingtoncs dot co dot za
On Tuesday 18 January 2005 1:08 pm, Hans du Plooy wrote:
I have a cron script that runs every - calls a program that analyse logs and crate graphs with the info. The way I set it up is simply to make a script that call the program, and stick it in the /etc/cron.hourly directory. Now I get a mail every hour. How do I get it not to send the mail? I know how to do this from the crontab file, but not if I use the cron.xyz directories directly.
Probably there's a more elegant way but...I'll remove the program from the directory and I'll put a script instead (that calls the program) so I can then control stdout and stderr. LIke this: #! /bin/sh /usr/bin/program > /dev/null 2> /dev/null Now you won't get any messages (nor any error messages) in your mail. HTH, Jorge
On Tuesday 18 January 2005 20:45, Jorge Fábregas wrote:
Probably there's a more elegant way but...I'll remove the program from the directory and I'll put a script instead (that calls the program) so I can then control stdout and stderr.
LIke this:
#! /bin/sh /usr/bin/program > /dev/null 2> /dev/null
Now you won't get any messages (nor any error messages) in your mail.
I think we're thinking two different things. The mails I get are empty - the program doesn't have any output. But cron sends a mail with the output (regardless of what the output is) anyway. I would just like to stop that. It works nicely through the crontab, but I'm always looking for more ways to do something... -- Kind regards Hans du Plooy Newington Consulting Services hansdp at newingtoncs dot co dot za
On Wednesday 19 January 2005 3:40 am, Hans du Plooy wrote:
I think we're thinking two different things. The mails I get are empty - the program doesn't have any output. But cron sends a mail with the output (regardless of what the output is) anyway. I would just like to stop that.
Well I think you should then read: man 5 crontab "If MAILTO is defined (and non-empty), mail is sent to the user so named. If MAILTO is defined but empty (MAILTO=""), no mail will be sent." Jorge
The Wednesday 2005-01-19 at 09:40 +0200, Hans du Plooy wrote:
I think we're thinking two different things. The mails I get are empty - the program doesn't have any output. But cron sends a mail with the output (regardless of what the output is) anyway. I would just like to stop that.
I think that it sends an empty email because the cron job or script finished with a non zero result code. The idea is, if it is zero, there was no error, so no email. If it is different, there was an error, so inform the user: email him. -- Cheers, Carlos Robinson
The Tuesday 2005-01-18 at 19:08 +0200, Hans du Plooy wrote:
I have a cron script that runs every - calls a program that analyse logs and crate graphs with the info. The way I set it up is simply to make a script that call the program, and stick it in the /etc/cron.hourly directory. Now I get a mail every hour. How do I get it not to send the mail? I know how to do this from the crontab file, but not if I use the cron.xyz directories directly.
I think you will be emailed only if the otuput code (errorlevel?) of your script is not 0. -- Cheers, Carlos Robinson
Carlos wrote regarding 'Re: [SLE] quiet cron' on Tue, Jan 18 at 13:26:
The Tuesday 2005-01-18 at 19:08 +0200, Hans du Plooy wrote:
I have a cron script that runs every - calls a program that analyse logs and crate graphs with the info. The way I set it up is simply to make a script that call the program, and stick it in the /etc/cron.hourly directory. Now I get a mail every hour. How do I get it not to send the mail? I know how to do this from the crontab file, but not if I use the cron.xyz directories directly.
I think you will be emailed only if the otuput code (errorlevel?) of your script is not 0.
Or if anything's emitted on stdout/stderr, IIRC (depending on the cron daemon) --Danny
Hi all,
I have a cron script that runs every - calls a program that analyse logs and crate graphs with the info. The way I set it up is simply to make a script that call the program, and stick it in the /etc/cron.hourly directory. Now I get a mail every hour. How do I get it not to send the mail? I know how to do this from the crontab file, but not if I use the cron.xyz directories directly.
Thanks Have you tried `script.sh 1>&2 /dev/null`? this will send stdout and stderr into the big dustbin in the sky. I dont think you will get mail from cron anymore after that (i had a similar problem with ntpdate) if you still get mails, then your script is sending them. BEWARE: those mails can be helpful if your script dies, like this you will never get any warning, so it may be better to just redirect stdout first and see if that works: `script.sh > /dev/null` - that way normal output will die, but any errors will still get mailed (as long as your
Hans du Plooy wrote: script behaves properly and writes to stdout/stderr) Hope that helps, H
participants (5)
-
Carlos E. R.
-
Danny Sauer
-
Hamish
-
Hans du Plooy
-
Jorge Fábregas