ITPub博客

首页 > Linux操作系统 > Linux操作系统 > The Three Unix File Time :atime, mtime, ctime (转自:Unix Power Tools 3rd ed.)

The Three Unix File Time :atime, mtime, ctime (转自:Unix Power Tools 3rd ed.)

原创 Linux操作系统 作者:lawzjf 时间:2007-09-07 00:00:00 0 删除 编辑

The difference between a change and a modification is the difference between altering the label on a package and altering its contents.

If someon says chmod a-w myfile, that is a change; if someone says echo foo >> myfile, that is a modification.

A change modifies the file's inode; a modification modifies the contents of the file itself. A file's modification time is also called the timestamp.

The access time is the last time the file was read or written.

The three times usually be written as ctime, mtime, atime.

In some unix documents, the ctime is incorrectly documented as the "create time". Do not believe them.

导致三种时间发生变化的不同情况分析:

读取文件,只会修改其access time。

编辑文件,三种时间都会变化。注意,即使用vi打开一个文件,未修改其任何内容,也算作对文件进行了编辑。

改变文件的权限属性,只会修改其change time。


[root@redhat ~]# cat test.acm
law is a good comrade
[root@redhat ~]# stat test.acm
File: `test.acm'
...
Access: 2007-08-27 06:42:16.000000000 +0800
Modify: 2007-08-27 06:33:20.000000000 +0800
Change: 2007-08-27 06:33:20.000000000 +0800


[root@redhat ~]# ls -l test.acm
-rwx--x--x 1 root root 22 Aug 27 06:33 test.acm


[root@redhat ~]# chmod 777 test.acm
[root@redhat ~]# stat test.acm
File: `test.acm'
...
Access: 2007-08-27 06:42:16.000000000 +0800
Modify: 2007-08-27 06:33:20.000000000 +0800
Change: 2007-08-27 06:43:04.000000000 +0800


[root@redhat ~]# vi test.acm
[root@redhat ~]# stat test.acm
File: `test.acm'
...
Access: 2007-08-27 06:44:44.000000000 +0800
Modify: 2007-08-27 06:44:44.000000000 +0800
Change: 2007-08-27 06:44:44.000000000 +0800

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/37724/viewspace-152616/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-18

  • 博文量
    279
  • 访问量
    934272