ctime和mtime的区别

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值