linux的三个时间
?
每個(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)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 无精子吃什么药能生精
- 下一篇: bzoj 1211 [HNOI2004]