23

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?

40

You can do:

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

To see what it's doing, or

lsof -ad3-999 -c rsync

to see what files it currently has opened.

| improve this answer | |
3

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

rsync -avz /something /somwhere >> ~/rsynclog
| improve this answer | |
0

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
| improve this answer | |
0

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.

| improve this answer | |
0

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"

| improve this answer | |

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.