> -----Original Message-----
> From: Todd A. Jacobs
> Sent: Thursday, January 23, 2003 5:28 PM
> Subject: Re: backup script sends large email to root?
> Is it cron doing it?
> 
> 
> On Thu, 23 Jan 2003, Bapi Ghosh wrote:
> 
> > tar .... > /dev/null 2>&1
> 
> This is backwards. You needs to redirect stderr before 
> redirecting stdout:
> 
>       foo 2>&1 > /dev/null

Beg to differ on the above... from man bash

Note  that  the order of redirections is significant.  For example, the
command
 
   ls > dirlist 2>&1
 
directs both standard output and standard error to  the  file  dirlist,
while the command
 
   ls 2>&1 > dirlist

directs  only the standard output to file dirlist, because the standard
error was duplicated as standard output before the standard output  was
redirected to dirlist.

> Or, the MAILTO line in the crontab can be tweaked (it works 
> in a top-down fashion):
>       
>       # Mail results to [EMAIL PROTECTED] until otherwise specified.
>       [EMAIL PROTECTED]
>       * * * * * foo
>       * * * * * bar
>       #
>       # No output on following items.
>       MAILTO=""
>       * * * * * baz
> 
> The foo and bar lines will have output mailed, but baz won't. I still 
> don't think it's a good idea to close output, whether using MAILTO or 
> /dev/null, but those are the options.
> 
> A much better technique would be to *minimize* output so that 
> you only get an email when a cron job fails. A simple way to
> do this would be:
> 
>       * * * * * foo 2>&1 > /dev/null || echo "Foo failed. Fix me."
> 
> Otherwise, you might never know there's been a problem.
> 

Nod! I too, want to see stderr from all cronjobs. But the above syntax will
still print stderr before the echo statement should foo fail. Functionally,
the following is equivelent.

* * * * * foo >/dev/null || echo "Foo failed. Fix me."

If you just want to see the echo statment without stderr, then...
* * * * * foo >/dev/null 2>&1 || echo "Foo failed. Fix me."

Steve Cowles



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to