Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I start with comparing two directories:

[root@135759 ]# rsync -av test1/ test2/
building file list ... done

sent 128 bytes  received 20 bytes  296.00 bytes/sec
total size is 6  speedup is 0.04

They both are in sync Now, let me create a file in test1 and copy it to test2

[root@135759 ]# touch test1/hello4.php
[root@135759 ]# scp test1/hello4.php  test2/hello4.php

I verify that those are same:

[root@135759 test2]# md5sum test1/hello4.php
d41d8cd98f00b204e9800998ecf8427e  hello4.php

[root@135759 test1]# md5sum test2/hello4.php
d41d8cd98f00b204e9800998ecf8427e  hello4.php

Thus, running rsync will show me 0 files. Why is the output not right ?

[root@135759 ]# rsync -avn test1/ test2/
building file list ... done

sent 116 bytes  received 24 bytes  280.00 bytes/sec
total size is 6  speedup is 0.04
share|improve this question
up vote 3 down vote accepted

The file contents are the same, so rsyinc is sending very little data. But I suspect that some of the metadata on the files is different. I am guessing creation versus modified timestamps maybe based on your example. Check those before running rsync the second time. When rysnc sees differing timestamps, it does do a "transfer" of that file, even if no file data is involved, and only metadata.

share|improve this answer
I ran more tests and it seems that rsync looks at the last modified time of the file, instead of only file contents. Is there a utility that allows me to list files based on the differences in them and not just update time ? – Stewie Apr 13 '11 at 19:40
This is exactly what rsync does. If two files have the exact same size and timestamps, there is no way to no the contents are different without reading the whole file at both source and destination. Rsync uses the timestamp and size has a short-cut to skip files, nothing more. There is an --ignore-timestamps option (or similar) that will always read all files on both sides of a transfer and compute signatures to make sure files are identical. – rmalayter Apr 14 '11 at 12:08
hey, I found out a way :)) Rsync has a -c (checksum) option. so, rsync -cav , calculates the file checksum and tells me exacly what files are different (while ignoring the similar files) – Stewie Apr 14 '11 at 14:05

rsync by default does 'quick' comparisons by file mtime and size; even local clock drift can sometimes cause problems with this, so if you really need to know that the files are absolutely identical before deciding to skip them for transfer, use rsync's --checksum option, which will checksum the file on each end and compare the results. Be forewarned that for operations involving large files, or many files, or both, that this option can be very CPU intensive and increase the time required to sync considerably.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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