11

This is referring to the matter stated here and I am also experiencing the same.

In one of my servers, I ran an rsync, to backup a huge directory (size greater than 300 Gb) to a different disk, mounted on same machine. The directory being rsynced contains thousands of directories and files. I issued a single rsync command, with 'nohup' and then pushed it in background using the '&' command. The complete command given on the remote bash shell (using putty) was:

nohup rsync -avh /some/local/dir /backup/ >> /opt/rsync.dec22.log &

Then just to check at what rate was the data being copied, I used 'iotop' command, and found that there were 3 rsync running with same parameters. On searching I found the link above which says that it is normal.

But doing an iotop to monitor only those and the only rsync processes running on the system, I see that one process is reading files, one is writing them, but one is idle. The behaviour seems to be good, as one process doing only one thing at a time, but what is the 3rd process doing (seen as the middle one in the image below)?

The iotop command I had used was:

iotop -p22250 -p22251 -p22252

Here is the screenshot for the iotop command output:

iotop command output showing 3 rsync process

I am asking this cause I use rsync a lot, and want to understand its behaviour for long term benefit. I even read the manual, but it says nothing of the forking.

1 Answer 1

9

rsync is a program designed to be a client and server. The server reads and the client writes. Imagine that instead of a single computer, you had computers over network, I'm sure it's lot more clear if you think that way.

Then there is the controller. As IO operations tend to come with certain amount of risk, an IO issue shouldn't cause total blocking or a crash. So, it creates a fork for each connection and sits in the background.

4
  • Thanks for knowledge. I understand it in the view of separate computers on network, each computer doing a part of the work in sync. But can you also refer me to the behaviour documentation where I can read more such stuff about rsync and also about the concept? Also would like to know how is the read data passed by the reading process to the process which is writing? Is the concept of IPC being used? Dec 24, 2012 at 4:44
  • 3
    @GautamSomani The official rsync page will be your best source for such. rsync.samba.org Also, the how it works is available here: rsync.samba.org/how-rsync-works.html If you want even further details, you probably have to dig into the source.
    – Grumpy
    Dec 24, 2012 at 5:50
  • The original author launches rsync locally. He doesn't connect to rsyncd so there's no way that daemon forks its child. And there's no network connections. So it's stil a question why rsync forks when executed locally. The answer is misleading and wrong.
    – drookie
    Feb 7, 2019 at 6:33
  • @drookie It doesn't matter if it's local or over network. It works the same way. It also explains this behavior in the official doc I linked right above your comment, which also says, "either within a local transfer, via a remote shell or via a network socket."
    – Grumpy
    Feb 9, 2019 at 1:29

You must log in to answer this question.

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