文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>关于文件的mtime ctime 和 atime的区别

关于文件的mtime ctime 和 atime的区别

时间:2009-07-31  来源:dolinux

描述一个文件更改时间时我们常常会看到mtime ,ctime,atime这几个字眼。
这里就这几个时间的问题我总结了一下。
access time  , atime在读取文件或执行文件时会修改
create time  , ctime在文件写入,更改所有者,权限。链接时文件的ctime会随之改变
modified time ,mtime 在文件写入时会改变。

ls -lu  或者 ls -l --time=atime 显示文件的atime
ls -lc 或者  ls -l --time=ctime 显示文件的ctime
ls -l    显示文件的mtime

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

1》atime
along@along-laptop:~/code/shell/shell/along$ ls -lu
总用量 4
-rwxr--r-- 1 along along 22 2009-07-31 18:09 file
along@along-laptop:~/code/shell/shell/along$ cat file
#!/bin/bash
echo "ad"
along@along-laptop:~/code/shell/shell/along$ ls -lu
总用量 4
-rwxr--r-- 1 along along 22 2009-07-31 18:09 file      

 //上面看到访问了文件但是atime没有改变,

//我在实验的时候访问文件和执行文件 后有时文件的atime会改变,但多数时间文件的atime没有变化。这可能和系统的设置有关,具体原因我还是不太清楚。也许就是上面说的mount是的moatime选项的问题。

2》ctime

along@along-laptop:~/code/shell/shell/along$ ls -lc
总用量 4
-rwxr--r-- 1 along along 22 2009-07-31 18:09 file
along@along-laptop:~/code/shell/shell/along$ cat >> file
ad
^C
along@along-laptop:~/code/shell/shell/along$ ls -lc
总用量 4
-rwxr--r-- 1 along along 25 2009-07-31 18:16 file
along@along-laptop:~/code/shell/shell/along$ chmod 744 file
along@along-laptop:~/code/shell/shell/along$ ls -lc
总用量 4
-rwxr--r-- 1 along along 25 2009-07-31 18:17 file

//上面的看到我们向文件写入内容,和改变文件权限,后文件的ctime改变了

3》mtime
along@along-laptop:~/code/shell/shell/along$ ls -l
总用量 4
-rw-r--r-- 1 along along 25 2009-07-31 18:16 file
along@along-laptop:~/code/shell/shell/along$ cat >> file
adflsdf
^C
along@along-laptop:~/code/shell/shell/along$ ls -l
总用量 4
-rw-r--r-- 1 along along 33 2009-07-31 18:18 file

//上面的可一看到当我们修改文件内容是文件的mtime改变了
相关阅读 更多 +
排行榜 更多 +
越野普拉多停车

越野普拉多停车

赛车竞速 下载
高速公路恐惧

高速公路恐惧

赛车竞速 下载
人群大炮

人群大炮

飞行射击 下载