how to put -ii output in log file and not on screen?
Ian! D. Allen
idallen at idallen.ca
Fri Apr 24 20:46:45 GMT 2009
What I want is a client-side log file itemized list of *all* the changes
that rsync did on the remote machine. Using "--log-file" doesn't
show everything. In particular, --log-file says nothing if the remote
directory was populated using hard links from a --link-dest source.
Any number of remote links and directories can be created, with no
mention of any of it in the log file.
The "-ii" (twice) option does secretly influence what gets logged in the
log file - it secretly tells rsync to log the files created from the
--link-dest sources, as well as its documented behaviour of displaying
them on standard output. The man page paragraph for --itemize-changes
hints at this behaviour, though it doesn't say that it affects the log
file output as well as what is sent to standard output:
"If you repeat the option, unchanged files will also be output"
It's misleading to say "unchanged" files, since --link-dest most certainly
creates directories and changes the link counts of the files it links.
Unfortunately, using "-ii" also spews the thousands of lines of output
uselessly on my screen/stdout, and I only want it in the log file. How do
I get the full output in the --log-file and not all over my screen?
Yes, I can use "-ii" and redirect the thousands of useless lines of
output to a file or /dev/null, but what a waste of I/O resources!
I tried using "-ii" to increase what I need in the log file but set an
empty --out-format="" (empty string) to suppress the standard output
display (keeping only the log file). Incredibly, using "-ii" and setting
--out-format="" has the unexpected side-effect of dropping all the
--link-dest entries from the log file! There is an awkward relationship
between --out-format and file logging that needs better documentation.
Suggested rsync man page corrections:
If you ask for an itemized list of changed attributes (either
--itemize-changes or adding "%i" to the --out-format setting),
the output (on the client) increases to mention more items.
Not mentioned are updates resulting from --link-dest sources,
unless you double the --itemize-changes option.
Causes rsync to log into a file some of what it is doing. Exactly
what is logged depends on whether the updates involve actual file
transfers (logged) or links from remote --link-dest sources (not
logged). Doubling the --itemize-changes option (i.e. "-ii") increases
what gets logged to the file (--link-dest changes are now logged),
but also generates duplicate output on standard output.
Requests a simple itemized list of the changes that are being
made to each file and directory, including attribute changes, but
not including link count changes or directory creations resulting
from --link-dest sources. This is exactly the same as specifying
--out-format='%i %n%L', and explicitly setting --out-format may
over-ride or cancel the use of --itemize-changes. If you repeat
the option, unchanged files and changes resulting from --link-dest
sources will also be output, but only if the receiving rsync is at
least version 2.6.7. (You can use -vv with older versions of rsync,
but that also turns on the output of other verbose messages.)
Repeating this option also simultaneously increases what changes
are logged via the --log-file option.
Setting this option to the null string (="") will have the side-effect
of disabling the all the effects and side-effects of --itemize-changes.
My current work-around is to abandon trying to use --log-file and to
parse the redirected output of "-ii" instead, at least until someone
sets me straight on how I can make *all* the update info appear in the
log file and not on standard output.
| Ian! D. Allen - idallen at idallen.ca - Ottawa, Ontario, Canada
| Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/
| College professor (Open Source / Linux) via: http://teaching.idallen.com/
| Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/
More information about the rsync