Tuma Wang
2014-Mar-26 10:00 UTC
redirect rsync's log to a log file together with other program
Hi, I'm writing a program to use rsync to do something, and I want to keep the output of both in the same log file. My program is writing log to /var/log/my.log via syslog() LOG_LOCAL0. I tried to use rsync's '--log-file=/var/log/my.log' option; it seems to work to some extent, but have some problems: 1. If I issue the rsync command directly on command line, rsync's log will be written to both the log file and the terminal (probably stdout). 2. IF I run my own program (which invokes rsync), rsync's log/output won't be written to the log file, but only to the terminal/stdout. I guess it's because syslog() is also writing to this file. How can I redirect both's log to this log file, and without sending rsync's log to the terminal/stdout? Thanks. --tuma -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20140326/ddeea6dd/attachment.html>
TJ Luoma
2014-Mar-26 21:42 UTC
redirect rsync's log to a log file together with other program
On Wed, Mar 26, 2014 at 6:00 AM, Tuma Wang <wangtuma at gmail.com> wrote:> Hi, > > I'm writing a program to use rsync to do something, and I want to keep the > output of both in the same log file. My program is writing log to > /var/log/my.log via syslog() LOG_LOCAL0. I tried to use rsync's > '--log-file=/var/log/my.log' option; it seems to work to some extent, but > have some problems:Don?t use --log-file Instead put this at the end of the rsync command: 2>&1 >> /var/log/my.log so instead of rsync {whatever} --log-file=?$LOG? use rsync {whatever} 2>&1 >> "$LOG? HTH -- TjL