免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2039 | 回复: 0
打印 上一主题 下一主题

[新手入门] atime, mtime, ctime的区别 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-01-02 16:58 |只看该作者 |倒序浏览

   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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP