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

Re: Silent Cron Jobs


afaik cron (by default) mails all output from a script. If i create a
cronjob I usually dump all stdout (just redirect it to /dev/null)
But I want to be informed of any errors so I keep stderr.


# this will get mailed
echo "My cool cron script"

 # this will not mail stdout, but stderr (see below for an example)
echo "My cooler cron script" > /dev/null

# this will send you a mail because there was output on stderr, if
there was output on stdout it wouldn't mail
/nonexistant/echo "My failing cron script" > /dev/null

Not this is untested and just a quick writeup but the general rule should apply


On Wed, Mar 26, 2008 at 3:05 PM, Curt Howland <Howland@priss.com> wrote:
>  Hash: SHA1
>  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.
>  Curt-
>  - --
>  Treason! http://blog.mises.org/archives/007926.asp
>  Version: GnuPG v1.4.6 (GNU/Linux)
>  iQEVAwUBR+pYQi9Y35yItIgBAQJkcgf/c8y5Sbd4WkNChuA2muNkprTVFy6JkMIs
>  8gHQReKiEJH6R4QHVTWRtElqjWHDcry15lCV6h2AIN5w+FIPKmvFcViA3rGk5jK3
>  Jr/NzC3twwtRaxhvUKDNrfr0VHmAjHeVxBdBHt287zejzDc9TCECcPBderco82rO
>  OwmDs7WuNzQrWZSz8VDGFhjxdJrdhUIVzgeSamD0xtt65gNvUj6GN2YxGeUODlTk
>  V9XfO6vxsrK3chBrag7Cz4EA5pPsyK3QoMtr/NrCPSBPbE2dT38hZAtz3dIN4yq1
>  ve2fmP7HMF24TtKhTKxkmKN6Qm3uOT8B9qiZ7VPrJsvldcSJVAHuAA==
>  =IgSr
>  -----END PGP SIGNATURE-----
>  --
>  To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
>  with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.

Reply to: