Linux-命令-基本-time,ctime,atime

Linux 时间属性:

-mtime(modify time) 修改时间

e.g. +7 七天之前; 7 第七天;-7最近7天

以下为摘抄:

atime:Access time,是在读取文件或者执行文件时更改,即文件最后一次被读取的时间。
说明: st_atime
          Time when file data was last accessed. Changed by  the
          following  functions:  creat(),  mknod(),  pipe(),
          utime(2), and read(2).

mtime:Modified time,是在写入文件时随文件内容的更改而更改,是指文件内容最后一次被修改的时间。
说明: st_mtime
          Time when data was last modified. Changed by the  fol-
          lowing  functions:  creat(), mknod(), pipe(), utime(),
          and write(2).

ctime:Change time,是在写入文件、更改所有者、权限或链接设置时随 Inode 的内容更改而更改,即文件状态最后一次被改变的时间。
说明: 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().
很多人把它理解成create time,包括很多误导人的书籍也是这么写。实际上ctime是指change time。

注意:
1、修改是文本本身的内容发生了变化(mtime)
      改变是文件的索引节点发生了改变(ctime)
2、如果修改了文件内容,则同时更新ctime和mtime
3、如果只改变了文件索引节点,比如修改权限,则只是改变了ctime

4、如果使用ext3文件系统的时候,在mount的时候使用了noatime参数则不会更新atime的信息,即访问文件之后atime不会被修改,而这个不代表真实情况

小知识:这三个 time stamp 都放在 inode 中。若mtime,atime修改, inode 就一定会改,相应的inode改了,那ctime 也就跟着要改了,之所以在mount option中使用 noatime, 就是不想 file system 做太多的修改, 从而改善读取性能.

查看文件的 atime、ctime 和 mtime。
# ls -lc filename        列出文件的 ctime
# ls -lu filename        列出文件的 atime
# ls -l  filename          列出文件的 mtime

--time-style=long-iso  --time-style 参数 格式化时间

-------------------- 阑心而慧智,心静而致远. --------------------
原文地址:https://www.cnblogs.com/mirrorlake/p/7337053.html