linux ls ctime mtime,find命令中 -atime -ctime -mtime的区别和实例

find命令中 -atime -ctime -mtime的区别和实例

日期:2011-11-07

点击:112

来源: 未知

分享至:

find -atime -ctime -mtime区别

atime、mtime与ctime的区别

access time  , atime在读取文件或执行文件时会修改

create time  , ctime在文件写入,更改所有者,权限。链接时文件的ctime会随之改变

modified time ,mtime 在文件写入时会改变。

ls -lu  或者 ls -l --time=atime 显示文件的atime

ls -lc 或者  ls -l --time=ctime 显示文件的ctime

ls -l    显示文件的mtime

[root@station206 test]# touch test.txt

[root@station206 test]# stat test.txt

File: `test.txt'

Size: 0               Blocks: 8          IO Block: 4096   regular

empty file

Device: fd00h/64768d    Inode: 1179651     Links: 1

Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2009-05-21 01:46:26.000000000 0800         ## atime

Modify: 2009-05-21 01:46:26.000000000 0800         ## mtime

Change: 2009-05-21 01:46:26.000000000 0800        ## ctime

[root@station206 test]# more test.txt              ## 访问文件

[root@station206 test]# stat test.txt

File: `test.txt'

Size: 0               Blocks: 8          IO Block: 4096   regular

empty file

Device: fd00h/64768d    Inode: 1179651     Links: 1

Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2009-05-21 01:47:21.000000000 0800           ## atime有变法了

Modify: 2009-05-21 01:46:26.000000000 0800

Change: 2009-05-21 01:46:26.000000000 0800

[root@station206 test]# echo asdf > test.txt          ## 添加内容

[root@station206 test]# stat test.txt

File: `test.txt'

Size: 5               Blocks: 16         IO Block: 4096   regular

file

Device: fd00h/64768d    Inode: 1179651     Links: 1

Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2009-05-21 01:47:21.000000000 0800           ## atime没有变法

,疑问?

Modify: 2009-05-21 01:48:14.000000000 0800           ## mtime有变法

Change: 2009-05-21 01:48:14.000000000 0800        ## ctime有变法

[root@station206 test]# chmod a x test.txt         ## 修改属性

[root@station206 test]# stat test.txt

File: `test.txt'

Size: 5               Blocks: 16         IO Block: 4096   regular

file

Device: fd00h/64768d    Inode: 1179651     Links: 1

Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2009-05-21 01:47:21.000000000 0800        ## atime没有变

Modify: 2009-05-21 01:48:14.000000000 0800        ## mtime没有变

Change: 2009-05-21 01:49:39.000000000 0800        ## ctime有变法

[root@station206 test]# vim test.txt             ## 编辑文件

[root@station206 test]# stat test.txt

File: `test.txt'

Size: 12              Blocks: 16         IO Block: 4096   regular

file

Device: fd00h/64768d    Inode: 1179653     Links: 1

Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2009-05-21 01:50:55.000000000 0800

Modify: 2009-05-21 01:50:55.000000000 0800

Change: 2009-05-21 01:50:55.000000000 0800        ## 都发生变法

[root@station206 test]# mv test.txt test.txt2

[root@station206 test]# stat test.txt

stat: cannot stat `test.txt': No such file or directory

[root@station206 test]# stat test.txt2

File: `test.txt2'

Size: 12              Blocks: 16         IO Block: 4096   regular

file

Device: fd00h/64768d    Inode: 1179653     Links: 1

Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2009-05-21 01:50:55.000000000 0800

Modify: 2009-05-21 01:50:55.000000000 0800

Change: 2009-05-21 01:51:52.000000000 0800        ##只有ctime发

生变法

atime 访问时间(access time):访问时间是文件最后一次被读取的时间。因此

阅读一个文件会更新它的访问时间,而它的改变时间并没有变化(有关文件状态

的信息没有被改变),它的修改时间也同样没有变化(文件内容本身没有被改变)

mtime 修改时间(modification time):文件内容最后被修改的时间。

ctime 改变时间(change time):文件状态(status)最后被改变的时间。

[root@station206 test]# touch -at 200701010000 test.txt2

[root@station206 test]# stat test.txt2

File: `test.txt2'

Size: 12              Blocks: 16         IO Block: 4096   regular

file

Device: fd00h/64768d    Inode: 1179653     Links: 1

Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2007-01-01 00:00:00.000000000 0800

Modify: 2009-05-21 01:50:55.000000000 0800

Change: 2009-05-21 01:53:57.000000000 0800

[root@station206 test]# touch -mt 200701010000 test.txt2

[root@station206 test]# stat test.txt2

File: `test.txt2'

Size: 12              Blocks: 16         IO Block: 4096   regular

file

Device: fd00h/64768d    Inode: 1179653     Links: 1

Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2007-01-01 00:00:00.000000000 0800

Modify: 2007-01-01 00:00:00.000000000 0800

Change: 2009-05-21 01:54:07.000000000 0800

[root@station206 test]# touch -ct 200701010000 test.txt2

[root@station206 test]# stat test.txt2

File: `test.txt2'

Size: 12              Blocks: 16         IO Block: 4096   regular

file

Device: fd00h/64768d    Inode: 1179653     Links: 1

Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/

root)

Access: 2007-01-01 00:00:00.000000000 0800

Modify: 2007-01-01 00:00:00.000000000 0800

Change: 2009-05-21 01:54:12.000000000 0800

## touch改不了ctime?可能只能修改系统时间才能修改ctime了。

Tags:

分享至:

验证码:

vdimgck.php

理智评论文明上网,拒绝恶意谩骂

用户名:

匿名发表

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值