- 论坛徽章:
- 0
|
atime: access time
mtime: modify time (timestamp)
ctime: change time
mtime 和ctime 的区别在于是更改文件内容,还是更改文件属性。前者是文件内容发生了变化,后者是文件的索引节点发生变化。
如,touch 文件abc.123,看atime, mtime, ctime
#istat abc.123
Inode 1271 on device 10/4 File
Protection: rw-r--r--
Owner: 0(root) Group: 0(system)
Link count: 1 Length 0 bytes
Last updated: Mon Jan 02 16:24:44 2006 (ctime)
Last modified: Mon Jan 02 16:24:44 2006 (mtime)
Last accessed: Mon Jan 02 16:24:53 2006 (atime)
# chmod a+x abc.123
修改文件属性,再看atime, mtime, ctime)。
# istat abc.123
Inode 1271 on device 10/4 File
Protection: rwxr-xr-x
Owner: 0(root) Group: 0(system)
Link count: 1 Length 0 bytes
Last updated: Mon Jan 02 16:39:30 2006
Last modified: Mon Jan 02 16:24:44 2006
Last accessed: Mon Jan 02 16:24:53 2006
其中ctime发生了变化。
最后修改文件内容
# echo foo >> abc.123
Inode 1271 on device 10/4 File
Protection: rwxr-xr-x
Owner: 0(root) Group: 0(system)
Link count: 1 Length 4 bytes
Last updated: Mon Jan 02 16:48:51 2006
Last modified: Mon Jan 02 16:48:51 2006
Last accessed: Mon Jan 02 16:24:53 2006
其中mtime, ctime都发生了变化,mtime被更新很容易理解,ctime 被更新也一样可以理解,因为文件内容被修改时,索引节点的length字段也随之变化。
atime: 访问时间是文件最后一次被读取的时间。因此阅读一个文件会更新它的访问时间,如:
# cat abc.123
foo
# istat abc.123
Inode 1271 on device 10/4 File
Protection: rwxr-xr-x
Owner: 0(root) Group: 0(system)
Link count: 1 Length 4 bytes
Last updated: Mon Jan 02 16:48:51 2006
Last modified: Mon Jan 02 16:48:51 2006
Last accessed: Mon Jan 02 16:55:14 2006
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/12476/showart_64888.html |
|