linux中atime mtime ctime
1.mtime(medify time):最後一次修改文件或目錄的時間
2.ctime(chang time) :最後一次改變文件或目錄(改變的是原數據即:屬性)的時間如:記錄該文件的inode節點被修改的時間。touch命令除了-d和-t選項外都會改變該時間。而且chmod,chown等命令也能改變該值。
3. atime(access time)::最後一次訪問文件或目錄的時間
對於文件: 當修改mtime時,ctime必須隨著改變.因為文件大小等都屬性;有人說說atime也一定會改變,要想修改文件必須先訪問;其實是不對的不必訪問文件就能修改其內容:如:#echo “This is a test !” >> /etc/issue,issue文件內容會變,但並沒有訪問文件,所以atime並沒有改變.
對於目錄: 訪問一個目錄其atime改變,mtime ,ctime不變;修改一個目錄:在一個目錄下touch一個文件,mtime與ctime會改變,atime不一定會變;如:
[root@station16 ~]# stat /tmp file: `/tmp' size: 135168 Blocks: 280 IO Block: 4096 directoryfevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:15:59.000000000 +0800modify: 2010-07-09 09:15:57.000000000 +0800change: 2010-07-09 09:15:57.000000000 +0800
[root@station16 ~]# cd /tmp
[root@station16 tmp]# touch text.txt
[root@station16 ~]# !sstat /tmp file: `/tmp' size: 135168 Blocks: 280 IO Block: 4096 directorydevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:15:59.000000000 +0800modify: 2010-07-09 09:31:39.000000000 +0800change: 2010-07-09 09:31:39.000000000 +0800
[root@station16 ~]#
atime改變,mtime ,ctime不變情況:
[root@station16 ~]# stat /tmp File: `/tmp' Size: 135168 Blocks: 280 IO Block: 4096 directorydevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:15:59.000000000 +0800modify: 2010-07-09 09:31:39.000000000 +0800change: 2010-07-09 09:31:39.000000000 +0800[root@station16 ~]# cd /tmp[root@station16 tmp]# lsaa text text.txt
[root@station16 ~]# !sstat /tmp file: `/tmp' size: 135168 Blocks: 280 IO Block: 4096 directorydevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:35:49.000000000 +0800modify: 2010-07-09 09:31:39.000000000 +0800change: 2010-07-09 09:31:39.000000000 +0800
查看文件的屬性:
使用stat命令可以查看三時間值:如
stat filename
也可使用:
ls -l file : 查看文件修改時間
ls -lc file: 查看文件狀態改動時間
ls -lu file: 查看文件訪問時間