Re: Runing a script under cron. Append stdout and, stderr to a log file, propagate stderr back to cron for email, reporting

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



"Alexander Georgiev" <alexander.georgiev@xxxxxxxxx> wrote:

I want to run a rsync-ing script in cron, generating a very verbose
-vv rsync log in a log file. The log file should combine both stderr
and stdin, which is easy:

     backup.sh >>/var/log/backup.log 2>&1

However, I would like to propagate only stderr to cron - in case there
has been an error, cron will mail me the assembled stderr output.
If you just want STDERR to get mailed to root (or wherever you specify), remove the "2>$1" from your cron entry. This is what instructs the shell to combine STDOUT with STDERR. Your cron entry should look like:

backup.sh >>/var/log/backup.log >> /var/log/backup.log


to append STDOUT output to backup.log. cron automatically mails any output from programs.

Cheers,
Dave

--
Politics, n. Strife of interests masquerading as a contest of principles.
-- Ambrose Bierce

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux