[clue-tech] mtime isn't

marcus hall marcus at tuells.org
Thu Apr 9 09:28:04 MDT 2009


On Thu, Apr 09, 2009 at 08:56:12AM -0600, chris fedde wrote:
> Here is an example to make this a bit more concrete:
> 
> date > t; sleep 3; cp t t.cp;
> perl -MFile::stat -le 'for ("t", "t.cp"){ $t = stat $_; print join " ",
> $t->atime,           $t->ctime, $t->mtime}'
> 1239288602 1239288599 1239288599
> 1239288602 1239288602 1239288602
> 
> Note especially that both ctime and mtime have been updated even though the
> content has not changed. Also atime on the original file because it was
> accessed to copy it.

What do you mean that the content has not changed??  The contents of t.cp
(actually whatever inode got allocated for that file) went from not existing
to containing whatever data was written to it by the cp program.  The
ctime certainly changed because the inode was changed as well (went from
free to allocated).

Now, from a higher level view, you may think that there was no logical
change to things, but from the filesystem's view, things have changed.
For instance, if you ran something like "find . -mtime -7" looking for the
files that need to be backed up because they have changed in the last
week, should it make a backup of t.cp?

Marcus Hall
marcus at tuells.org


More information about the clue-tech mailing list