I am running rsync in a cronjob and redirect the output of rsync in the cronjob using

/opt/rsync.sh ... > /var/log/rsync.log 2>&1

I know, I can make rsync output just a summary of number of bytes transferred and so on. I also know I can make rsync verbose printing the percentage of each file transferred. But when I redirect the verbose output into a file, it produces a list of outputs for each file since it frequently sends the percentage to stdout.

How can I get something in between, print every file transferred and a summery but not multiple lines for the process percentage of each file?

  • show us an example output how you get it and how you expect it
    – djdomi
    Sep 20 '19 at 8:16

As I understand it, you are doing rsync and redirecting STDOUT to a file - something like

rsync -avz mydir targetserver: > rsync.log

If that's so, then you can simply use the argument --log-file=rsync.log to tell it to write to said logfile directly instead of using STDOUT. So the command line above can instead be

rsync --log-file=rsync.log -avz mydir targetserver: 

Another option would be to remove the --progress option from the rsync command, so that the percentage does not show.

For a script, it might make more sense to replace the --progress with an output format that lists what type of changes have been made. That's easily done using the itemize-changes option. From the man page:

-i, --itemize-changes

Requests a simple itemized list of the changes that are being made to each file, including attribute changes. This is exactly the same as specifying --out-format='%i %n%L'. If you repeat the option, unchanged files 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).

  • Thanks. I am actually using a cronjob, I am using rsync from a script that also outputs more stuff. I have it clarified in my question. Sep 20 '19 at 8:41
  • I've added info about how you could change the output instead.
    – Jenny D
    Sep 20 '19 at 9:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.