I just have viewed /etc/resolv.conf
file using a cat
command (or opening it with mcedit). Now when i list file details using ls -ul
the "access time" doesn't change/update - have the same, old value. It's strange since for any other files "access time" is updated after cat.
-
This answer suggests that many filesystems disable updating the atime for performance reasons, perhaps the case for you?– Eric RenoufDec 31, 2017 at 12:13
1 Answer
Invoke df /etc/resolv.conf
and note under what mountpoint it exists. Example from my Kubuntu:
$ df /etc/resolv.conf
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 806600 9660 796940 2% /run
Surprisingly my resolv.conf
is under /run
. True:
$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 29 Nov 24 2016 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
Then we need to know its mount options:
$ mount | grep " /run "
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=806600k,mode=755)
Pay attention to atime
-related option. In my case this is relatime
. man 8 mount
explains:
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 tonoatime
, but doesn't breakmutt
or other applications that need to know if a file has been read since the last time it was modified.)
(Check the rest of *atime
options to have a full picture.)
relatime
is very common nowadays. It saves frequent writing yet still provides atime
to programs that need it. In my Kubuntu only these mounts don't use relatime
:
$ mount | grep -v relatime
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
Probably you broadly use relatime
too.
It's strange since for any other files "access time" is updated after
cat
.
Maybe "the previous access time was earlier than the current modify or change time", so the atime
was updated. Or "other files" are under a different mountpoint (e.g. with strictatime
option). Note my resolv.conf
is on a different filesystem than the whole /etc/
(/etc/resolv.conf
is a symlink to elsewhere), so in general you shouldn't even assume that "files" in the same directory are on the same filesystem, under the same mountpoint with the same options.
Whatever your setup is, now you know how to investigate the issue.