Linux文件的三個時間概念
系統保存了這三個時間,分別是Accesstime(訪問時間),Modify time(修改時間)和Change time(狀態時間)。
官方文檔給出的解釋:
st_atime
Time when file datawas last accessed. Changed by the
following functions: creat(), mknod(), pipe(),
utime(2), andread(2).
st_mtime
Time when data waslast modified. Changed by the fol-
and write(2).
st_ctime
Time when filestatus was last changed. Changed by the
following functions: chmod(), chown(), creat(),
link(2), mknod(), pipe(), unlink(2), utime(), and
write().
文件的 Accesstime,atime 是在讀取文件或者執行文件時更改的。
文件的 Modified time,mtime 是在寫入文件時隨文件內容的更改而更改的。
文件的 Create time,ctime 是在寫入文件、更改所有者、權限或鏈接設置時隨 Inode 的內容更改而更改的。
因此,更改文件的內容即會更改 mtime 和 ctime,但是文件的 ctime 可能會在 mtime 未發生任何變化時更改 - 在權限更改,但是文件內容沒有變化的情況下。
ll -c 查看文件的ctime
ll -u 查看文件的atime
ll 查看文件的mtime
touch -m命令修改時間戳 實際上變化的是mtime即文件的修改時間
Linux文件的三個時間概念