On Mon, Oct 30, 2006 at 10:06:53AM +1100, Peter Chubb wrote:
> >>>>> "Leslie" == Leslie Katz <[EMAIL PROTECTED]> writes:
> 
> Leslie> Michael Chesterton wrote:
> Leslie> When I look at the man page for "find", I see that "-atime
> Leslie> /n/" means file was last accessed /n/*24 hours ago, while
> Leslie> "-ctime /n/" means file's status was last changed /n/*24 hours
> Leslie> ago. However, I don't really grasp the significance of that
> Leslie> difference for present purposes.

You should almost never use atime or ctime in find; mtime
is almost always what you're after.  In particular, atime
is useless if you do backups since it will always reflect
the time of the last backup or greater.

> atime: When the file was last read or written to.
> ctime: when the inode (metadata) was last changed.  Metadata changes
>        that are tracked include file creation, change of ownership,
>        change of permissions.

A nice way to see the differences is to play with the 'stat' command:

$ touch eg
$ stat --printf=" atime=%x\n mtime=%y\n ctime=%z\n" eg
 atime=2006-10-30 14:47:13.000000000 +1100
 mtime=2006-10-30 14:47:13.000000000 +1100
 ctime=2006-10-30 14:47:13.000000000 +1100
$ echo fish > eg        # should change mtime
$ stat --printf=" atime=%x\n mtime=%y\n ctime=%z\n" eg
 atime=2006-10-30 14:47:13.000000000 +1100
 mtime=2006-10-30 14:47:35.000000000 +1100
 ctime=2006-10-30 14:47:35.000000000 +1100
$ cat eg        # should change atime only
fish
$ stat --printf=" atime=%x\n mtime=%y\n ctime=%z\n" eg
 atime=2006-10-30 14:48:01.000000000 +1100
 mtime=2006-10-30 14:47:35.000000000 +1100
 ctime=2006-10-30 14:47:35.000000000 +1100
$ 
$ chmod go-wr eg        # should change ctime only
$ stat --printf=" atime=%x\n mtime=%y\n ctime=%z\n" eg
 atime=2006-10-30 14:48:01.000000000 +1100
 mtime=2006-10-30 14:47:35.000000000 +1100
 ctime=2006-10-30 14:48:14.000000000 +1100
$ echo dog > eg
$ stat --printf=" atime=%x\n mtime=%y\n ctime=%z\n" eg
 atime=2006-10-30 14:48:01.000000000 +1100
 mtime=2006-10-30 14:48:33.000000000 +1100
 ctime=2006-10-30 14:48:33.000000000 +1100

Note that ctime is always greater than or equal to mtime
since mtime changes the node info, (in particular the
size attribute I guess!)

Matt

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to