Date: Sat, 20 Jul 2002 10:01:52 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Steve Warwick <ukla@attbi.com> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Cron: mailing owner: how to stopit! Message-ID: <20020720090152.GA12356@happy-idiot-talk.infracaninophi> In-Reply-To: <B95E0C32.32ED%ukla@attbi.com> References: <B95E0C32.32ED%ukla@attbi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jul 19, 2002 at 06:34:26PM -0700, Steve Warwick wrote: > I have several scripts that run very frequently and email the owner > every time the script is run. > I have gone through all the setup / config files but cannot figure > out how to stop this from happening. Anyone have a list of locations > I should look for this configuration / option? cron will mail back any output on stdout or sterr from your scripts. If you don't want this e-mail then you have three choices: i) Set the MAILTO= variable at the top of the crontab (See the crontab(5) man page). This won't suppress the e-mail, just redirect it somewhere else. Instead of choosing your least favourite user as a sacrificial victim, sending the mail to 'nobody' will dispose of it humanely. Even better, setting MAILTO="" will suppress e-mail output entirely. Unfortunately that is rather a blunt instrument: you will be disposing of all of the e-mail generated by every job in the crontab. ii) Redirect the stdout and stderr of your command to a log file, or to /dev/null. Append ' >/dev/null 2>&1' to the end of the command line in the crontab to send all the output to oblivion, or ' >>/var/tmp/logfile 2>&1' to append it to a logfile. iii) (and this is my preferred method) Rewrite your scripts, or write a wrapper script around your commands so that they emit no output for a normal, successfully completed run. On the other hand, should there be a problem, make your script print out as detailed a diagnostic error message as suits you. That way, you only get e-mail when something goes horribly wrong. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way Tel: +44 1628 476614 Marlow Fax: +44 0870 0522645 Bucks., SL7 1TH UK To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020720090152.GA12356>