日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

linux的三个时间

發(fā)布時(shí)間:2023/11/27 生活经验 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux的三个时间 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?

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

?

三個(gè)時(shí)間的定義

mtime:當(dāng)文件的內(nèi)容數(shù)據(jù)改變時(shí),會更新這個(gè)時(shí)間。(文件數(shù)據(jù)部分的內(nèi)容)ctime:當(dāng)文件的狀態(tài)改變時(shí),會更新這個(gè)時(shí)間。(權(quán)限或?qū)傩?#xff09;atime:當(dāng)數(shù)據(jù)被讀取時(shí),會更新這個(gè)時(shí)間。

可以通過stat命令查看文件的三個(gè)時(shí)間

[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: -

?

三個(gè)時(shí)間的說明

  • mtime

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

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

改變其文件內(nèi)容,發(fā)現(xiàn)mtime已經(jīng)發(fā)生變化

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

在mtime發(fā)生改變時(shí),文件的ctime也會跟著改變,因?yàn)槲募?nèi)容的改變,其Blocks,Size等元數(shù)據(jù)也發(fā)生了改變。

[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,我們發(fā)現(xiàn)test文件的權(quán)限為644

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

通過chmod 666 test,改變其權(quán)限,發(fā)下ctime發(fā)生了變化

[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

查看當(dāng)文件被讀取時(shí),atime發(fā)生變化

[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

?

當(dāng)讀取文件時(shí),會修改atime

當(dāng)改變文件內(nèi)容時(shí),會修改ctime和mtime

當(dāng)改變權(quán)限等元數(shù)據(jù)信息時(shí),會修改ctime

轉(zhuǎn)載于:https://www.cnblogs.com/fox-zhang/p/8027105.html

總結(jié)

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

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。