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 參數 格式化時間