"Alexander Georgiev" alexander.georgiev@gmail.com 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