今天在整理find命令的時候,突然對這兩個的區別產生了疑惑,下面詳細解釋一下:
ctime : ChangeTime 既:改變時間
mtime:ModifyTime 既:更改時間
這下出問題了,到底有啥區別?看下面例子
[zhoupan@DesktopComputer /tmp/test 16:47:48 ]$ touch 1.txt
[zhoupan@DesktopComputer /tmp/test 16:47:53 ]$ stat 1.txt
File: ‘1.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 80ch/2060d Inode: 135319815 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ zhoupan) Gid: ( 1000/ zhoupan)
Access: 2017-02-25 16:47:53.993566804 +0800
Modify: 2017-02-25 16:47:53.993566804 +0800
Change: 2017-02-25 16:47:53.993566804 +0800
Birth: -
[zhoupan@DesktopComputer /tmp/test 16:48:01 ]$ echo 'lala' > 1.txt
[zhoupan@DesktopComputer /tmp/test 16:48:12 ]$ stat 1.txt
File: ‘1.txt’
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: 80ch/2060d Inode: 135319815 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ zhoupan) Gid: ( 1000/ zhoupan)
Access: 2017-02-25 16:47:53.993566804 +0800
Modify: 2017-02-25 16:48:12.707131768 +0800
Change: 2017-02-25 16:48:12.707131768 +0800
Birth: -
[zhoupan@DesktopComputer /tmp/test 16:48:16 ]$ chmod 777 1.txt
[zhoupan@DesktopComputer /tmp/test 16:48:38 ]$ stat 1.txt
File: ‘1.txt’
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: 80ch/2060d Inode: 135319815 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 1000/ zhoupan) Gid: ( 1000/ zhoupan)
Access: 2017-02-25 16:47:53.993566804 +0800
Modify: 2017-02-25 16:48:12.707131768 +0800
Change: 2017-02-25 16:48:38.924522287 +0800
Birth: -
[zhoupan@DesktopComputer /tmp/test 16:48:42 ]$ cat 1.txt
lala
[zhoupan@DesktopComputer /tmp/test 16:50:56 ]$ stat 1.txt
File: ‘1.txt’
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: 80ch/2060d Inode: 135319815 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 1000/ zhoupan) Gid: ( 1000/ zhoupan)
Access: 2017-02-25 16:50:56.624321154 +0800
Modify: 2017-02-25 16:48:12.707131768 +0800
Change: 2017-02-25 16:48:38.924522287 +0800
Birth: -
[zhoupan@DesktopComputer /tmp/test 16:51:03 ]$ mv 1.txt 2.txt
[zhoupan@DesktopComputer /tmp/test 16:57:16 ]$ stat 2.txt
File: ‘2.txt’
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: 80ch/2060d Inode: 135319815 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 1000/ zhoupan) Gid: ( 1000/ zhoupan)
Access: 2017-02-25 16:50:56.624321154 +0800
Modify: 2017-02-25 16:48:12.707131768 +0800
Change: 2017-02-25 16:57:16.305488877 +0800
Birth: -
[zhoupan@DesktopComputer /tmp/test 16:57:20 ]$
當我查看文件,ctime,mtime都不變,當我往文件中寫入內容時,都更新,當我更改文件權限時,ctime變,mtime不變,於是終結如下:
mtime:當文件內容更改時,mtime纔會更新
ctime:更改文件任何屬性,其都會更新