stat [filename]
显示的access time应该是最近一次访问改文件的时间。包括读取和写入。
但是,我无论用less读取还是用编辑器打开修改内容,或者用echo 1 >> [filename]也不会改变access time。(后两者实际上已经改变了文件的实际内容和inode信息了,所以ctime和mtime都已经改变了,但是atime没有变!)
只有当我用编辑器打开,移动光标后,access time才改变了。
这是为什么呢?这个access time怎么这么不靠谱?
找到答案了,还是wiki给力阿。
atime updates are by far the biggest IO performance deficiency that Linux has today. Getting rid of atime updates would give us more everyday Linux performance than all the pagecache speedups of the past 10 years, _combined_.
As of 2.6.30 (9 June 2009), Linux defaults to relatime
,[3] so that it will not update atime on all file reads. The behavior offers sufficient performance for most purposes and should not break any significant applications. Extended discussion of filesystem performance preceded the decision.[4] Indeed, relatime
by default was the first patch Linux applied following the 2.6.29 release. In initial patches relatime
only updated atime if atime < mtime or atime < ctime;
你的机器上是变的吗?
这是我的结果:
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ stat AUTHORS
File: `AUTHORS'
Size: 365 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 9439976 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ chenqi) Gid: ( 1000/ chenqi)
Access: 2012-08-29 18:57:35.430069290 +0800
Modify: 2012-08-29 18:57:35.354069292 +0800
Change: 2012-08-29 18:57:35.354069292 +0800
Birth: -
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ cat AUTHORS
Tim Ansell <mithro@mithis.net>
Phil Blundell <pb@handhelds.org>
Seb Frankengul <seb@frankengul.org>
Holger Freyther <holger@moiji-mobile.com>
Marcin Juszkiewicz <marcin@juszkiewicz.com.pl>
Chris Larson <kergoth@handhelds.org>
Ulrich Luckas <luckas@musoft.de>
Mickey Lauer <mickey@Vanille.de>
Richard Purdie <rpurdie@rpsys.net>
Holger Schurig <holgerschurig@gmx.de>
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ stat AUTHORS
File: `AUTHORS'
Size: 365 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 9439976 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ chenqi) Gid: ( 1000/ chenqi)
Access: 2012-08-29 18:57:35.430069290 +0800
Modify: 2012-08-29 18:57:35.354069292 +0800
Change: 2012-08-29 18:57:35.354069292 +0800
Birth: -
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ date
Wed Aug 29 19:04:17 CST 2012
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$
你的机器上是变的吗?
这是我的结果:
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ stat AUTHORS
File: `AUTHORS'
Size: 365 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 9439976 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ chenqi) Gid: ( 1000/ chenqi)
Access: 2012-08-29 18:57:35.430069290 +0800
Modify: 2012-08-29 18:57:35.354069292 +0800
Change: 2012-08-29 18:57:35.354069292 +0800
Birth: -
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ cat AUTHORS
Tim Ansell <mithro@mithis.net>
Phil Blundell <pb@handhelds.org>
Seb Frankengul <seb@frankengul.org>
Holger Freyther <holger@moiji-mobile.com>
Marcin Juszkiewicz <marcin@juszkiewicz.com.pl>
Chris Larson <kergoth@handhelds.org>
Ulrich Luckas <luckas@musoft.de>
Mickey Lauer <mickey@Vanille.de>
Richard Purdie <rpurdie@rpsys.net>
Holger Schurig <holgerschurig@gmx.de>
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ stat AUTHORS
File: `AUTHORS'
Size: 365 Blocks: 8 IO Block: 4096 regular file
Device: 803h/2051d Inode: 9439976 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ chenqi) Gid: ( 1000/ chenqi)
Access: 2012-08-29 18:57:35.430069290 +0800
Modify: 2012-08-29 18:57:35.354069292 +0800
Change: 2012-08-29 18:57:35.354069292 +0800
Birth: -
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$ date
Wed Aug 29 19:04:17 CST 2012
chenqi@chenqi-OptiPlex-760:~/poky/bitbake$
我的是变的
Jiang@local ~/tmp/test $ stat test
文件:"test"
大小:0 块:0 IO 块:4096 普通空文件
设备:11h/17d Inode:268877 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 1000/ Jiang) Gid:( 1000/ Jiang)
最近访问:2012-08-29 19:06:22.200085281 +0800
最近更改:2012-08-29 19:06:22.200085281 +0800
最近改动:2012-08-29 19:06:22.200085281 +0800
创建时间:-
Jiang@local ~/tmp/test $ cat test
Jiang@local ~/tmp/test $ stat test
文件:"test"
大小:0 块:0 IO 块:4096 普通空文件
设备:11h/17d Inode:268877 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 1000/ Jiang) Gid:( 1000/ Jiang)
最近访问:2012-08-29 19:06:51.364086914 +0800
最近更改:2012-08-29 19:06:22.200085281 +0800
最近改动:2012-08-29 19:06:22.200085281 +0800
Jiang@local ~/tmp/test $ echo hello > test
Jiang@local ~/tmp/test $ stat test
文件:"test"
大小:6 块:8 IO 块:4096 普通文件
设备:11h/17d Inode:268877 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 1000/ Jiang) Gid:( 1000/ Jiang)
最近访问:2012-08-29 19:06:51.364086914 +0800
最近更改:2012-08-29 19:08:02.916090921 +0800
最近改动:2012-08-29 19:08:02.916090921 +0800
创建时间:-
Jiang@local ~/tmp/test $ !cat
cat test
hello
Jiang@local ~/tmp/test $ stat test
文件:"test"
大小:6 块:8 IO 块:4096 普通文件
设备:11h/17d Inode:268877 硬链接:1
权限:(0644/-rw-r--r--) Uid:( 1000/ Jiang) Gid:( 1000/ Jiang)
最近访问:2012-08-29 19:08:28.600092359 +0800
最近更改:2012-08-29 19:08:02.916090921 +0800
最近改动:2012-08-29 19:08:02.916090921 +0800
创建时间:-
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。