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了。