[CentOS] difference between cron and shell invocation.

Tue Dec 7 15:39:34 UTC 2010
Robert Heller <heller at deepsoft.com>

At Tue, 7 Dec 2010 10:21:27 -0500 (EST) CentOS mailing list <centos at centos.org> wrote:

> 
> Question.  In a chained cron job like this:
> 
> sshfs  .  .  . && /usr/bin/rsync .  .  . | /bin/mail -s .  .  . && .
>  .  .
> 
> Is there anyway to get a failure message from the first part to be
> emailed or logged?
> 
> Given the resolution of this problem I gather that sshfs must not
> have been found and therefore I would expect an error to be reported
> somewhere.  The chained commands evidently interfered with the
> propagation of this error which would have immediately identified
> the source of the problem. Is it possible to get errors from the
> individual parts of such chained commands forwarded to an email
> address, or logged in the system log, or both?

It is probably easiest to create a shell script with all of the chaining
there and use shell script flow control to deal with mailing/logging
errors:

#!/bin/sh -e
sshfs  .  .  . 
/usr/bin/rsync .  .  . 2>&1 | /bin/mail -s .  .  . 
..

Or something like that (eg using '|| error-handling/reporting code'
instead of -e).

> 

-- 
Robert Heller             -- 978-544-6933 / heller at deepsoft.com
Deepwoods Software        -- http://www.deepsoft.com/
()  ascii ribbon campaign -- against html e-mail
/\  www.asciiribbon.org   -- against proprietary attachments