[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Silent Cron Jobs



Hi,

>
> I tried to whip up a small cron job, I put a short script
> in /etc/cron.daily thinking that this would work.
>
> Well, yes, it works, but I get mail sent to me by cron explaining that
> the job executed successfully.
>
> I'd prefer not to get the mail. I don't get mail for any of the other
> jobs in cron.daily, and I don't understand enough of bash scripting
> to see how mine is different from the others.
>
> If all else fails I could just add a line to /etc/crontab, but I think
> the Debian way is so very much better coordinated and elegant.

just add this line at the beggining of your script :

exec >/dev/null

this will discard any standard output and should be enough (you only get a 
mail when your program produces some output). You can also discard stderr by 
adding 2>&1 at the end of this line, but this is not a good idea as you could 
miss some important error message.

-- 
Cédric Lucantis


Reply to: