Files in use

Martin Pool mbp at
Mon Dec 3 13:25:33 EST 2001

On 28 Nov 2001, matthew.2.burgess at wrote:

> Hello all
> I have been watching and learning from this list for a couple of months
> now.. Here is my first question.
> If rsync comes across a file that is in use by somebody. What happens?
> Does the file get skipped or does the entire transfer halt?

rsync tries to open the file using the operating system's normal
mechanism.  If the OS allows it to be opened while it is in use, then
that's what will happen -- this may result in rsync seeing a file
which is in an inconsistent state.  (This is just the same as cp, tar,

To avoid this, you need to either arrange your own interlock between
the process using the file and rsync (e.g. by stopping the daemon
during backup), or see if your OS has mandatory file locks.

On the destination rsync always writes to a temporary file and then
renames it.  This operation is atomic on Unix, so processes will
either see the old file or the new one.  Processes that have the old
file open it will continue to use it even after it's been unlinked.
Note that if you use --partial then rsync will perform this rename
when the transfer is cancelled even if the file is only partially


More information about the rsync mailing list