Atime 值在文件创建后仅更改一次

Atime 值在文件创建后仅更改一次

我已经用明确的给定值安装了磁盘 - atime:

mount -o mount -o atime /dev/disk1 /myDisk

然后我创建了一个文件

touch file_A

执行此操作后,统计输出如下所示:

Access: 2013-08-30 11:38:48.141970758 +0200
Modify: 2013-08-30 11:38:48.141970758 +0200
Change: 2013-08-30 11:38:48.141970758 +0200

cat /myDisk/file_A统计输出更改后但仅更改一次:

    Access: 2013-08-30 11:39:11.141970758 +0200
    Modify: 2013-08-30 11:38:48.141970758 +0200
    Change: 2013-08-30 11:38:48.141970758 +0200

然后多次执行 cat 根本不会改变访问时间值。这有什么问题吗?这种行为从何而来?我预计在对该文件进行每次猫操作后,访问时间都会发生变化。为什么只显示第一次访问?

(使用 noatime 选项挂载磁盘会导致另一种行为,任何 cat 更改 stat 中的访问时间。仍然等于修改和更改)

答案1

relatime安装时可以使用该选项吗?它应该是介于atime和之间的某种中间方式noatime,不会引起那么多的 I/O,atime但仍然不会破坏破坏noatime.

这是以下描述man 8 mount

   relatime
   Update  inode  access times relative to modify or change time.  
   Access time is only updated if the previous access time was 
   earlier than the current modify or change time. (Similar to noat‐
   ime, but doesn't break mutt or other applications that need to 
   know if a file has been read since the last time it was modified.)

   Since Linux 2.6.30, the kernel defaults to the behavior provided 
   by this option (unless noatime was  specified), and the 
   strictatime option is required to obtain traditional  semantics. 

   In addition, since Linux 2.6.30, the file's last access time is 
   always  updated  if  it  is more than 1 day old.

相关内容