I have an rsync job that has been added to a crontab and when it's running, I can only check that there's a rsync PID and confirm with htop that it's eating up n amount of CPU and RAM.

What I'd like to do is to monitor what files are actually being rsync'ed in realtime...when I want to. FYI I haven't passed any verbose option to the command nor have I added some logging. I really just want to check what's being rsync'ed on demand.

Any idea how I could achieve that?


You can do (in POSIX shells, including bash):

strace -e open,openat $(ps -o lwp= -LC rsync | sed 's/^/-p/')

Or in zsh:

strace -e open,openat -p${^$(ps -o lwp= -LC rsync)}

Or in fish

strace -e open,openat -p(ps -o lwp= -LC rsync)

Or in rc/es:

strace -e open,openat -p`{ps -o lwp= -LC rsync}

To see what it's doing, or

lsof -ad3-999 -c rsync

to see what files it currently has opened.

  • At the time or writing (linux 4.15.0) you probably want strace -e openat instead – piro Oct 6 '20 at 21:38
  • Thanks @piro, I've added it. – Stéphane Chazelas Oct 7 '20 at 6:36

The most simple solution would be redirecting the output of rsync to a logfile.

rsync -avz /something /somwhere >> ~/rsynclog
  • the goal of the question is to have a status of the current rsyincing, without having any verbose/logging on [Probably to be more flexible, and to avoid always logging (and ending up with tons of lines of rarely needed rsync logs)] – Olivier Dulac Sep 18 '20 at 11:59

Another way you could is if you know the rough directory you'll be syncing (ie, we'll use the directory 'movies' for example) you can use a combination of lsof and grep:

lsof | grep rsync | grep movies

lsof will list your open files, pipes the output to grep to find any opened by rsync, pipes that output to grep to find the directory/file which is open.


Here are two ways

With screen: Attach screen session to your cron job:

screen rsync --progress src dst

this will allow you to re attach to the rsync jobb anytime you want to check what files its currently processing (just be sure to be the same user as the one that launched the rsync job) with

screen -x

With logging add logging to your rsync job:

rsync --log-file=/tmp/rsync-status.txt  src dst

then follow the log in real time with:

 tail -f /tmp/rsync-status.txt

As Király István suggested, I am running

rsync -ravz /Users/jkirby/Music/iTunes/* .

which gives output like

Jeffs-MBP-2:2016-08-15 jkirby$ rsync -ravz /Users/jkirby/Music/iTunes/* .
building file list ... done
Temp File 1.tmp
Temp File.tmp

From that output I can see what directory is being copied.

In the case where rsync is copying a lot of large files slowly, I monitor that directory using watch like so. This way I can see the temp file that rsync creates and I can see the size growing on the file currently being copied.

watch -n1 "~/Music/iTunes"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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