[atime][ctime][mtime] – 差別
* modification time (mtime):當該檔案的『內容資料』變更時,就會更新這個時間! 內容資料指的是檔案的內容,而不是檔案的屬性喔!
* status time (ctime):當該檔案的『狀態 (status)』改變時,就會更新這個時間,舉例來說, 像是權限與屬性被更改了,都會更新這個時間啊~
* access time (atime):當『該檔案的內容被取用』時,就會更新這個讀取時間 (access)。 舉例來說,我們使用 cat 去讀取 ~/.bashrc ,就會更新 atime 了。
舉例:
[root@linux ~]# ls -l /etc/man.config
-rw-r–r– 1 root root 4506 Apr 8 19:11 /etc/man.config
[root@linux ~]# ls -l –time=atime /etc/man.config
-rw-r–r– 1 root root 4506 Jul 19 17:53 /etc/man.config
[root@linux ~]# ls -l –time=ctime /etc/man.config
-rw-r–r– 1 root root 4506 Jun 25 08:28 /etc/man.config
以下資料轉載自 鳥哥
# modification time (mtime):
當該檔案的『內容資料』變更時,就會更新這個時間!內容資料指的是檔案的內容,而不是檔案的屬性或權限喔!
# status time (ctime):
當該檔案的『狀態 (status)』改變時,就會更新這個時間,舉例來說,像是權限與屬性被更改了,都會更新這個時間啊。
# access time (atime):
當『該檔案的內容被取用』時,就會更新這個讀取時間 (access)。舉例來說,我們使用 cat 去讀取 /etc/man.config , 就會更新該檔案的 atime 了
ls -lc filename 列出文件的 ctime
ls -lu filename 列出文件的 atime
ls -l filename 列出文件的 mtime
範例 :
清除 /var/log/*.* 和現在日期比對超過30天的資料檔案
/usr/bin/find /var/log/ -name “*.*” -mtime 30 -daystart -exec rm {} \;