關於LINUX三種時間戳的詳細說明(帶實驗)
Linux系統將時間標記分三類:
atime( A ccess time):檔案上次被讀取的時間。
ctime(status C hange time):檔案的屬性或內容上次被修改的時間。
mtime( M odified time):檔案的內容上次被修改的時間。
下面我將用實驗給大家講解一下:
[[email protected] ~]# touch a.txt ==》建立檔案a.txt
[[email protected] ~]# stat a.txt ==》檢視時間戳
File: "a.txt"
Size: 0 Blocks: 0 IO Block: 4096 普通空檔案
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:04.130157512 +0800
Change: 2018-03-10 13:29:04.130157512 +0800
[[email protected] ~]# echo 1>> a.txt ==》向檔案a.txt追加內容
[[email protected]
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通檔案
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:19.351159892 +0800==》時間戳改變
Change: 2018-03-10 13:29:19.351159892 +0800 ==》時間戳改變
[[email protected] ~]# chmod +x a.txt ==》修改檔案a.txt的許可權
[[email protected] ~]# stat a.txt ==》檢視修改許可權後的檔案時間戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通檔案
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:29:04.130157512 +0800
Modify: 2018-03-10 13:29:19.351159892 +0800
Change: 2018-03-10 13:29:42.156153774 +0800==》時間戳改變
[[email protected] ~]# cat a.txt ==》檢視檔案a.txt
[[email protected] ~]# stat a.txt ==》檢視檔案a.txt的時間戳
File: "a.txt"
Size: 1 Blocks: 8 IO Block: 4096 普通檔案
Device: fd00h/64768dInode: 674903 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:30:00.010155999 +0800 ==》時間戳改變
Modify: 2018-03-10 13:29:19.351159892 +0800
Change: 2018-03-10 13:29:42.156153774 +0800
[[email protected] ~]# vim a.txt ==》向檔案a.txt新增內容
daskhdjkas
"a.txt" 1L, 11C 已寫入
[[email protected] ~]# stat a.txt ==>檢視檔案a.txt的時間戳
File: "a.txt"
Size: 11 Blocks: 8 IO Block: 4096 普通檔案
Device: fd00h/64768dInode: 674908 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-03-10 13:30:34.652158960 +0800 ==》時間戳改變
Modify: 2018-03-10 13:30:34.652158960 +0800==》時間戳改變
Change: 2018-03-10 13:30:34.653158940 +0800==》時間戳改變