rsync and the file's mtime

Jeff Bearer jbearer at pittsburghlive.com
Mon Nov 25 14:31:02 EST 2002


On Sun, 2002-11-24 at 20:48, Adrian Ho wrote:
> On Sun, Nov 24, 2002 at 05:46:06AM -0500, Jeff Bearer wrote:
> > I'm trying to write a script that runs rsync to pull files and then
> > detect which ones of them have changed.  The problem is when I run
rsync
> > without the -t flag the mtime gets updated every run, not only when
the
> > file changes.  It this a bug, by design, or un-avoidable? 
> 
> By design -- "man rsync" and read the "-t" option description.

But if the file isn't modified, the modified time shouldn't be updated,
from my testing I've found out that it is.  The description of -t does
not explain that it should behave that way.  

When a modified file is synced without the -t flag both the atime and
the mtime should be the same, then the next rsync it should only update
the atime if the file has not changed.

> > Is there any way to make rsync behave as desired?
> 
> Yeah, and you mentioned it in your problem description.  Is there a
> reason why you can't use "-t"?

-t sets the mtime of the file to the same as the mtime on the source
file.  That doesn't help with the -N file test operator because the
atime will always be after the mtime so it will never return true.

I forgot to mention that I'd prefer not to store any meta data about the
file, and if I used the -t flag I'd have to store the mtime and compare
it to the mtime of the file every run to see if it's changed.

I'm still interested on a fresh idea on how to find modified files after
a rsync, without storing meta data.


-- 
Jeff Bearer, RHCE
Webmaster, PittsburghLIVE.com
Winner 2002 Eppy Award, Best U.S. Newspaper Website




More information about the rsync mailing list