免费注册 查看新帖 |

Chinaunix

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

linux文件的 atime ctime mtime [复制链接]

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

Each file has three time stamps, which record the last time that certain operations were performed on the file:
  • access (read the file's contents)
  • change the status (modify the file or its attributes)
  • modify (change the file's contents)
    1。atime:最后一次读这个文件的时间,如使用more来读这个文件
    2。ctime:最后一次修改该文件的时间,如使用chmod来修改这个文件的属性
    3。mtime:最后一次修改该文件内容的时间,如使vi来修改这个文件的内容

    使用ls看一个文件的时候,看到的是mtime


    下面作几个测试
    1.依次建立3个文件1.txt   2.txt   3.txt(使用touch命令)
    2.touch一个文件时候,应该这个文件的3个time是一样的(还没有查证)
    3.使用命令
    find . -cnewer 2.txt
    find . -newer 2.txt
    find . -anewer 2.txt
    结果都是3.txt
    4.现在修改一下1.txt的属性
    chmod 700 1.txt
    在使用ls -al --full-time来看这些文件的属性,看到各个文件的时间跟没有执行上面的命令之前的时间是一样的,因为ls中看到的是mtime
    在使用
    find . -cnewer 2.txt看看结果
    就会是1.txt跟3.txt,因为我们刚才才修改了1.txt的属性,所以1.txt也比2.txt要新


    同样道理,我们more 一下1.txt,再使用
    find . -anewer 2.txt
    看看结果跟没有more 1.txt有什么不同





    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/22557/showart_161591.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

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

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP