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

2007-09-23 Thread David G. Miller

Alexander Georgiev [EMAIL PROTECTED] 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 21

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@centos.org
http://lists.centos.org/mailman/listinfo/centos


[CentOS] Runing a script under cron. Append stdout and stderr to a log file, propagate stderr back to cron for email reporting

2007-09-22 Thread Alexander Georgiev
Dear List,

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 21

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.

I tried the following:

$ (./backup.sh  /var/log/backup.log) 21 | tee -a /var/log/backup.log

which propagates the stderr to cron, but lines written to
/var/log/backup.log are out of sequence - for example if the contents
of backup.sh are:

#!/bin/bash

echo out 1 1
echo out 2 1
echo out 3 1
echo out 4 1
echo err 5 2
echo out 6 1
echo out 7 1
echo out 8 1

I get in /var/log/backup.log:

out 1
out 2
out 3
out 4
out 6
out 7
out 8
err 5

I would like the lines in their initial sequence.

Do you know a shell trick or a tool that I can use to achive desired goal?

Best regards,
alex
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


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

2007-09-22 Thread Ignacio Vazquez-Abrams
On Sat, 2007-09-22 at 17:11 +0300, Alexander Georgiev wrote:
 I would like the lines in their initial sequence.
 
 Do you know a shell trick or a tool that I can use to achive desired goal?

Can't be done. stdout and stderr aren't synchronized.

-- 
Ignacio Vazquez-Abrams [EMAIL PROTECTED]

PLEASE don't CC me; I'm already subscribed


signature.asc
Description: This is a digitally signed message part
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos