linux中ctime,mtime,atime的区别

 当你同熟练的UNIX用户进行交谈时,你常常会听到他们傲慢地讲出术语“改变时间(change time)”和“修改时间(modification time)”。对于许多人(和许多字典而言),改变和修改是相同的。这里会有什么不一样那?
node


    改变和修改之间的区别在因而改某个组件的标签仍是更改它的内容。若是有人说chmod a-w myfile,那么这是一个改变;若是有人说echo foo >> myfile,那么 
这是一个修改。改变是文件的索引节点发生了改变;修改是文本自己的内容发生了变化。[文件的修改时间也叫时间标志 (timestamp).]

    只要讨论改变时间和修改时间,就不可能不提到“访问时间(access time)”.访问时间是文件最后一次被读取的时间。所以阅读一个文件会更新它的访问时间,当它的改变时间并无变化(有关文件的信息没有被改变),它的修改时间也一样如此(文件自己没有被改变)

有时,在许多地方改变时间或者“ctime”被错误地写成“建立时间”,包括某些UNIX参考手册。不要相信他们
ide

下面是我man出来的内容,仅供参考!

     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。
spa


touch后,文件的三个时间应该都会改变,能够试一试。
orm


问题描述
文件的 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 作太多的修改, 而改善讀取效能.
索引

相关文章
相关标签/搜索