The Three Unix File Time :atime, mtime, ctime (转自:Unix Power Tools 3rd ed.)

The difference between a change and a modification is the difference between altering the label on a package and altering its contents.

If someon says chmod a-w myfile, that is a change; if someone says echo foo >> myfile, that is a modification.

A change modifies the file's inode; a modification modifies the contents of the file itself. A file's modification time is also called the timestamp.

The access time is the last time the file was read or written.

The three times usually be written as ctime, mtime, atime.

In some unix documents, the ctime is incorrectly documented as the "create time". Do not believe them.

导致三种时间发生变化的不同情况分析:

读取文件,只会修改其access time。

编辑文件,三种时间都会变化。注意,即使用vi打开一个文件,未修改其任何内容,也算作对文件进行了编辑。

改变文件的权限属性,只会修改其change time。


[root@redhat ~]# cat test.acm
law is a good comrade
[root@redhat ~]# stat test.acm
File: `test.acm'
...
Access: 2007-08-27 06:42:16.000000000 +0800
Modify: 2007-08-27 06:33:20.000000000 +0800
Change: 2007-08-27 06:33:20.000000000 +0800


[root@redhat ~]# ls -l test.acm
-rwx--x--x 1 root root 22 Aug 27 06:33 test.acm


[root@redhat ~]# chmod 777 test.acm
[root@redhat ~]# stat test.acm
File: `test.acm'
...
Access: 2007-08-27 06:42:16.000000000 +0800
Modify: 2007-08-27 06:33:20.000000000 +0800
Change: 2007-08-27 06:43:04.000000000 +0800


[root@redhat ~]# vi test.acm
[root@redhat ~]# stat test.acm
File: `test.acm'
...
Access: 2007-08-27 06:44:44.000000000 +0800
Modify: 2007-08-27 06:44:44.000000000 +0800
Change: 2007-08-27 06:44:44.000000000 +0800

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/37724/viewspace-152616/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/37724/viewspace-152616/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值