3

I am rsyncing a directory from machine B to machine A. rsync command is run on machine B.

On machine A, what kind of information can I get about this rsync process (progress/amount of data downloaded etc.) without sshing into machine B?

7
  • What network connection does machine B use to connect to machine A?
    – Silent-Bob
    Commented Oct 21, 2015 at 8:59
  • @Silent-Bob local lan.
    – user13107
    Commented Oct 21, 2015 at 9:11
  • I meant what protocol. rsh, ssh, ...?
    – Silent-Bob
    Commented Oct 21, 2015 at 9:26
  • @Silent-Bob ssh
    – user13107
    Commented Oct 21, 2015 at 9:31
  • enable verbose output to see the files being transferred, rsync -v
    – Creek
    Commented Oct 22, 2015 at 4:14

2 Answers 2

6

You can specify an option to remote system to log eg.

--remote-option=--log-file=/path/to/log/rsync.log

this is an example from a small rsync run

2015/10/21 10:59:43 [10785] receiving file list
2015/10/21 10:59:43 [10785] created directory stack2
2015/10/21 10:59:43 [10785] cd+++++++++ ./
2015/10/21 10:59:43 [10785] >f+++++++++ Filexxx
2015/10/21 10:59:43 [10785] >f+++++++++ logfile
2015/10/21 10:59:43 [10785] >f+++++++++ logfile.sh
2015/10/21 10:59:43 [10785] cd+++++++++ dir1/
2015/10/21 10:59:43 [10785] >f+++++++++ dir1/FileA
2015/10/21 10:59:43 [10785] >f+++++++++ dir1/FileB
2015/10/21 10:59:43 [10785] >f+++++++++ dir1/FileC
2015/10/21 10:59:43 [10785] >f+++++++++ dir1/filec
2015/10/21 10:59:43 [10785] cd+++++++++ dir2/
2015/10/21 10:59:43 [10785] >f+++++++++ dir2/filea
2015/10/21 10:59:43 [10785] >f+++++++++ dir2/fileb
2015/10/21 10:59:43 [10785] sent 240 bytes  received 1,703 bytes  total size 1,051
1
  • I like this answer but I'm choosing the other as it works on an already running rsync command (even when remote-log option is not given).
    – user13107
    Commented Oct 23, 2015 at 2:26
3

Assuming you have enough permissions, you can either strace the receiving rsync process or use lsof to see what files it has open.

Find the rsync process pid, eg using pgrep rsync, but choose the child as there will probably be two. Then use eg

strace -p 4484 -e rename

where 4484 is the found pid. It will show you each new file being created as it is renamed from the temporary name. You can simplify the output a bit with:

pid=$(pgrep -n rsync)
strace -p "$pid" -e rename 2>&1 | sed 's/.*", //;s/) = 0//'

Alternatively, use eg

 watch ls -l /proc/4484/fd/1

which seems to be the file descriptor being used to write to the temp file. This will show you at least the directory it is in.

3
  • The strace command did not work. It said attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
    – user13107
    Commented Oct 23, 2015 at 2:24
  • watch ls -l worked. It showed the file being copied currently.
    – user13107
    Commented Oct 23, 2015 at 2:25
  • 1
    The strace needs you to be the same user as rsync, or root, so perhaps it will work if you do sudo strace ..., if you can.
    – meuh
    Commented Oct 23, 2015 at 6:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .