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 directory
fevice: fd00h/64768d Inode: 2555905 Links: 8
access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)
access: 2010-07-09 09:15:59.000000000 +0800
modify: 2010-07-09 09:15:57.000000000 +0800
change: 2010-07-09 09:15:57.000000000 +0800
[root@station16 ~]# cd /tmp
[root@station16 tmp]# touch text.txt
[root@station16 tmp]# cd
[root@station16 ~]# !s
stat /tmp
file: `/tmp'
size: 135168 Blocks: 280 IO Block: 4096 directory
device: fd00h/64768d Inode: 2555905 Links: 8
access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)
access: 2010-07-09 09:15:59.000000000 +0800
modify: 2010-07-09 09:31:39.000000000 +0800
change: 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 directory
device: fd00h/64768d Inode: 2555905 Links: 8
access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)
access: 2010-07-09 09:15:59.000000000 +0800
modify: 2010-07-09 09:31:39.000000000 +0800
change: 2010-07-09 09:31:39.000000000 +0800
[root@station16 ~]# cd /tmp
[root@station16 tmp]# ls
aa text text.txt
[root@station16 tmp]# cd
[root@station16 ~]# !s
stat /tmp
file: `/tmp'
size: 135168 Blocks: 280 IO Block: 4096 directory
device: fd00h/64768d Inode: 2555905 Links: 8
access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)
access: 2010-07-09 09:35:49.000000000 +0800
modify: 2010-07-09 09:31:39.000000000 +0800
change: 2010-07-09 09:31:39.000000000 +0800
[root@station16 ~]#
使用
stat
命令可以查看三时间值
:
如
stat filename
也可使用
:
ls -l file :
查看文件修改时间
ls -lc file:
查看文件状态改动时间
ls -lu file:
查看文件访问时间
touch
命令
[options]
选项的时间格式
[[CC]YY]MMDDhhmm[.ss]
说明
:
表示世纪
YY 表示年
MM 表示月
DD 表示日
hh 表示小时
mm 表示分钟
ss 表示秒
201001311200.34
CCYYMMDDhhmm ss
表示时间为2010年1月31日12点0分34秒
options :
-t:
后面可接时间,其格式如上所述
-a
:仅修改
access time
-c
:仅修改时间,而不建立文件
-m
:仅修改
mtime
例如:将
issue
文件日期改为
2008/07/15
13:13
[root@station16 ~]# ls -l /etc/issue
-rw-r--r-- 1 root root 80 Jul 8 09:03 /etc/issue
[root@station16 ~]# touch -t 0807151313 /etc/issue
[root@station16 ~]# !l
ls -l /etc/issue
-rw-r--r-- 1 root root 80 Jul 15 2008 /etc/issue
[root@station16 ~]# stat /etc/issue
File: `/etc/issue'
Size: 80 Blocks: 16 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 3014852 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2008-07-15 13:13:00.000000000 +0800
Modify: 2008-07-15 13:13:00.000000000 +0800
Change: 2010-07-09 09:51:46.000000000 +0800
注意到我们改变了
issue
的
mtime
与
atime
,并没有改变
ctime
此时的
ctime
记录的是当前时间。