6

ファイルのアクセス時間を取得するために stat を使用しています (現在の日付は 2013 年 10 月 23 日です)。

[juan@JN-LNXSVR-02 labfiles]$ stat nursery
  File: `nursery'
  Size: 837         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 139539      Links: 1
Access: (0644/-rw-r--r--)  Uid: (  500/    juan)   Gid: (  500/    juan)
Access: 2013-10-22 18:03:20.703888346 -0400
Modify: 2013-10-21 16:57:07.801165793 -0400

次に、ファイルを編集して変更せずに閉じ、統計を再度送信します

juan@JN-LNXSVR-02 labfiles]$ vi nursery
[juan@JN-LNXSVR-02 labfiles]$ stat nursery
  File: `nursery'
  Size: 837         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 139539      Links: 1
Access: (0644/-rw-r--r--)  Uid: (  500/    juan)   Gid: (  500/    juan)
Access: 2013-10-22 18:03:20.703888346 -0400
Modify: 2013-10-21 16:57:07.801165793 -0400
Change: 2013-10-21 16:57:07.801165793 -0400

アクセス時間は変わらないのですが、なぜですか?

noatime 属性が見つかりませんでした

juan@JN-LNXSVR-02 labfiles]$ grep noatime /proc/mounts
[juan@JN-LNXSVR-02 labfiles]$

マウント コマンドの出力は次のとおりです。

[juan@JN-LNXSVR-02 labfiles]$ マウント

/dev/mapper/vg_jnlnxsvr02-lv_root on / type ext4 (rw)

/proc タイプ proc の proc (rw)

/sys の sysfs タイプ sysfs (rw)

/dev/pts の devpts type devpts (rw,gid=5,mode=620)

/dev/shm 上の tmpfs タイプ tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")


/boot タイプ ext4 (rw) の /dev/sda1
なし /proc/sys/fs/binfmt_misc タイプ binfmt_misc (rw)

/var/lib/nfs/rpc_pipefs の sunrpc タイプ rpc_pipefs (rw)

[juan@JN-LNXSVR-02 ラボファイル]$
4

1 に答える 1

11

の出力を含めていただけますmountか? 多分あなたのディスクはでマウントされていnoatimeますか?

EDIT(再度)relatime毎回ではなく、変更後に読み取るときに一度だけ更新します。writeLinux 2.6.30以降、これは標準オプションのようですread。しかし、write+ read+readは最初の読み取りに対してのみ更新します (その後の変更ごとに 1 回)。

アクセス時刻が変更時刻よりも新しい場合、読み取りのみの場合、オプションを使用して(またはオプションなしで)マウントした場合、アクセス時刻は更新されません。relatimeatime

からman mount:

noatime
 Do not update inode access times on this filesystem (e.g., for faster access on
 the news spool to speed up news servers).

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 noatime, 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.

記録として、古い動作に戻したい場合は、 を使用してstrictatimeください。

Allows to explicitly requesting full atime updates. This makes it possible for
kernel to defaults to relatime or noatime but still allow userspace to override
it. For more details about the default system mount options see /proc/mounts.
于 2013-10-23T19:59:48.033 に答える