分类: LINUX
2013-07-15 17:47:28
1.mtime(medify time):最后一次修改文件或目录的时间
2.ctime(chang time) :最后一次改变文件或目录(改变的是原数据即:属性)的时间如:记录该文件的inode节点被修改的时间。touch命令除了-d和-t选项外都会改变该时间。而且chmod,chown等命令也能改变该值。
3. atime(access time)::最后一次访问文件或目录的时间
对于文件: 当修改mtime时,ctime必须随着改变.因为文件大小等都属性;有人说说atime也一定会改变,要想修改文件必须先访问;其实是不对的不必访问文件就能修改其内容:如:#echo “This is a test !” >> /etc/issue,issue文件内容会变,但并没有访问文件,所以atime并没有改变.
对于目录: 访问一个目录其atime改变,mtime ,ctime不变;修改一个目录:在一个目录下touch一个文件,mtime与ctime会改变,atime不一定会变;如:
[root@station16 ~]# stat /tmp file: `/tmp' size: 135168 Blocks: 280 IO Block: 4096 directoryfevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:15:59.000000000 +0800modify: 2010-07-09 09:15:57.000000000 +0800change: 2010-07-09 09:15:57.000000000 +0800
[root@station16 ~]# cd /tmp
[root@station16 tmp]# touch text.txt
[root@station16 ~]# !sstat /tmp file: `/tmp' size: 135168 Blocks: 280 IO Block: 4096 directorydevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:15:59.000000000 +0800modify: 2010-07-09 09:31:39.000000000 +0800change: 2010-07-09 09:31:39.000000000 +0800
[root@station16 ~]#
atime改变,mtime ,ctime不变情况:
[root@station16 ~]# stat /tmp File: `/tmp' Size: 135168 Blocks: 280 IO Block: 4096 directorydevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:15:59.000000000 +0800modify: 2010-07-09 09:31:39.000000000 +0800change: 2010-07-09 09:31:39.000000000 +0800[root@station16 ~]# cd /tmp[root@station16 tmp]# lsaa text text.txt
[root@station16 ~]# !sstat /tmp file: `/tmp' size: 135168 Blocks: 280 IO Block: 4096 directorydevice: fd00h/64768d Inode: 2555905 Links: 8access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)access: 2010-07-09 09:35:49.000000000 +0800modify: 2010-07-09 09:31:39.000000000 +0800change: 2010-07-09 09:31:39.000000000 +0800
查看文件的属性:
使用stat命令可以查看三时间值:如
stat filename
也可使用:
ls -l file : 查看文件修改时间
ls -lc file: 查看文件状态改动时间
ls -lu file: 查看文件访问时间