Capturing output

Patrick Strasser past at
Wed Mar 5 18:30:49 EST 2003

Tom Freeman wrote:
> Hi folks,
> I am running rsync via a perl script run in a cronjob.
> my $message = `/usr/bin/rsync --rsh=/usr/local/openssh/bin/ssh -avu
> $directory $destination`;
> I want to be able to write this data
> to a log file, so that if things don't work, I can find out what's wrong.
> Is this a perl type question rather
> than something I can do with rsync...?

You can do it by shell:

`/usr/bin/rsync --youroptions $directory $destination 2&>1 > $yourlogfile`

This logs stdout and stderr to your log file
If you don't like stderr in your output, leave out '2&>1'. If you only 
like to have stderr, add '2&> $yourlogfile' instead of the rest.

Engineers motto: cheap, good,fast - choose any two
Patrick Strasser <past at sbox dot tugraz dot at>

More information about the rsync mailing list