日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

linux的三个时间

發布時間:2023/11/27 59 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux的三个时间 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

   每個文件都有兩部分組成,數據和元數據,linux文件的三個時間就記錄在元數據中,分別為atime(access time),ctime(status time),mtime(modify time)

?

三個時間的定義

mtime:當文件的內容數據改變時,會更新這個時間。(文件數據部分的內容)ctime:當文件的狀態改變時,會更新這個時間。(權限或屬性)atime:當數據被讀取時,會更新這個時間。

可以通過stat命令查看文件的三個時間

[root@fox ~]# stat testFile: ‘test’Size: 0             Blocks: 0          IO Block: 4096   regular empty file
Device: fd00h/64768d    Inode: 33594037    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2017-12-12 11:28:24.930239437 +0800
Modify: 2017-12-12 11:28:24.930239437 +0800
Change: 2017-12-12 11:28:24.930239437 +0800Birth: -

?

三個時間的說明

  • mtime

通過ls -l test查看test文件的mtime #ls -l顯示出來的時間即為mtime

[root@fox ~]# ls -l test
-rw-r--r--. 1 root root 0 Dec 12 11:28 test

改變其文件內容,發現mtime已經發生變化

[root@fox ~]# echo 111 > test
[root@fox ~]# ls -l test
-rw-r--r--. 1 root root 4 Dec 12 11:32 test

在mtime發生改變時,文件的ctime也會跟著改變,因為文件內容的改變,其Blocks,Size等元數據也發生了改變。

[root@fox ~]# stat testFile: ‘test’Size: 4             Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 33594037    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2017-12-12 11:28:24.930239437 +0800
Modify: 2017-12-12 11:32:12.666074114 +0800
Change: 2017-12-12 11:32:12.666074114 +0800Birth: -
  • ctime

通過ls -l test,我們發現test文件的權限為644

[root@fox ~]# ls -l test
-rw-r--r--. 1 root root 4 Dec 12 11:32 test

通過chmod 666 test,改變其權限,發下ctime發生了變化

[root@fox ~]# ls -l --time=ctime test
-rw-r--r--. 1 root root 4 Dec 12 11:32 test
[root@fox ~]# chmod 666 test
[root@fox ~]# ls -l --time=ctime test
-rw-rw-rw-. 1 root root 4 Dec 12 11:45 test
  • atime

查看當文件被讀取時,atime發生變化

[root@fox ~]# ls -l --time=atime test
-rw-rw-rw-. 1 root root 4 Dec 12 11:28 test
[root@fox ~]# cat test
111
[root@fox ~]# ls -l --time=atime test
-rw-rw-rw-. 1 root root 4 Dec 12 11:48 test

?

當讀取文件時,會修改atime

當改變文件內容時,會修改ctime和mtime

當改變權限等元數據信息時,會修改ctime

轉載于:https://www.cnblogs.com/fox-zhang/p/8027105.html

總結

以上是生活随笔為你收集整理的linux的三个时间的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。