[CentOS] difference between cron and shell invocation.

m.roth at 5-cent.us m.roth at 5-cent.us
Tue Dec 7 15:40:23 UTC 2010


James B. Byrne 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?
>
If you're going to get that complicated, why not just write a short shell
script, and run that via cron. Then you can set your environment
explicitly (as opposed to in your crontab, which some folks like to do).
Also, if you want logs from each piece, you could then break it up, and
dump/read stuff from temp files.

         mark




More information about the CentOS mailing list