
正文
linux中ctime,mtime,atime的区别
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
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
的内容更改而更改的。
文件的 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 做太多的修改,
而改善讀取效能.








