今天在整理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:更改文件任何属性,其都会更新