[clue-tech] mtime isn't

chris fedde chris at fedde.us
Thu Apr 9 08:56:12 MDT 2009


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.


On Tue, Apr 7, 2009 at 11:05 PM, David L. Anselmi <anselmi at anselmi.us>wrote:

> chris fedde wrote:
>
>> On Tue, Apr 7, 2009 at 8:44 PM, David L. Willson <DLWillson at thegeek.nu
>> >wrote:
>>
>>  Why is that when I copy a file from one place to another, the mtime
>>> updates?
>>>
>> >
>
>> Mtime is the time when the file's inode was modified. The file system
>> sees that the copy is a new inode so mtime is updated.
>>
>
> What Chris said.  Except I think mtime is when the file data changes. ctime
> is the inode time.  So now tell me why mv doesn't change the mtime (or
> atime).  And besides ctime, what other times change?  And with cp, what
> other times change?
>
> So you can use -p if you don't want the times changed.
>
> Dave
>
>
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://www.cluedenver.org/mailman/listinfo/clue-tech
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cluedenver.org/pipermail/clue-tech/attachments/20090409/d08497b1/attachment.html


More information about the clue-tech mailing list