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

Re: crontab $MAILTO question



DvB <dvanbalen@jam.rr.com> writes:

> Alec <alec1976nyc@yahoo.com> writes:
> 
> > Hi
> > 
> > I make backups using a cron job and I set MAILTO=""
> > Can I configure cron to mail me
> > a) *only* when there were errors
> > b) email only STDERR (not STDOUT)
> > 
> 
> 
> I assume you're asking about some type of special cron functionality
> which e-mails automatically... however, I would probably do this with a
> script... i.e.
> 
> #! /usr/bin/sh
> 
> #backup my stuff
> foo_bar_backup_tool baz.bktarget;
> 
> #howl if there's an error
> if [ $? -ne 0 ]
> then
>         echo "Oh crap!" | mail -s "bk error" me@mybox
> fi
> 


You would then, of course, run this script from the crontab... ;-)



Reply to: