码迷,mamicode.com
首页 > 系统相关 > 详细

linux中ctime,mtime,atime的区别

时间:2014-08-14 08:12:38      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:style   使用   io   文件   ar   问题   cti   div   

     st_atime

           Time when file data was last accessed. Changed by  the
           following   functions:   creat(),   mknod(),   pipe(),
           utime(2), and read(2).

     st_mtime
           Time when data was last modified. Changed by the  fol-
           lowing  functions:  creat(), mknod(), pipe(), utime(),
           and write(2).

     st_ctime
           Time when file status was last changed. Changed by the
           following   functions:   chmod(),   chown(),  creat(),
           link(2),  mknod(),  pipe(),  unlink(2),  utime(),  and
           write().

ls显示出的time应该是mtime。

 

问题描述
文件的 ctime、mtime、atime 之间有什么区别? 
配置信息
解决方法
文件的 Access time,atime 是在读取文件或者执行文件时更改的。
文件的 Modified time,mtime 是在写入文件时随文件内容的更改而更改的。
文件的 Create time,ctime 是在写入文件、更改所有者、权限或链接设置时随 Inode 的内容更改而更改的。 

因此,更改文件的内容即会更改 mtime 和 ctime,但是文件的 ctime 可能会在 mtime 未发生任何变化时更改 - 在权限更改,但是文件内容没有变化的情况下。 
ls(1) 命令可用来列出文件的 atime、ctime 和 mtime。
ls -lc filename         列出文件的 ctime
ls -lu filename         列出文件的 atime
ls -l filename          列出文件的 mtime 

    atime不一定在访问文件之后被修改,因为:使用ext3文件系统的时候,如果在mount的时候使用了noatime参数那么就不会更新atime的 信息。而这是加了 noatime 取消了, 不代表真實情況.反正, 這三個 time stamp 都放在 inode 中.若 mtime, atime 修改, inode 就一定會改, 既然 inode 改了, 那 ctime 也就跟著要改了.之所以在 mount option 中使用 noatime, 就是不想 file system 做太多的修改, 而改善讀取效能.

linux中ctime,mtime,atime的区别,布布扣,bubuko.com

linux中ctime,mtime,atime的区别

标签:style   使用   io   文件   ar   问题   cti   div   

原文地址:http://www.cnblogs.com/ghgyj/p/3911621.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!