The second call to cat a file does not update the access time. I was expecting the access time to be updated ever time a file contents gets displayed.
I see the same behaviour if I open the file in web browser. Its access time does not get updated consistently.
Am I misunderstanding access time? What is different between the two cat calls?
$ touch test $ stat test File: `test' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: 803h/2051d Inode: 152694 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1001/ aaron) Gid: ( 1001/ aaron) Access: 2012-08-21 11:05:40.586020996 +0200 Modify: 2012-08-21 11:05:40.586020996 +0200 Change: 2012-08-21 11:05:40.586020996 +0200 Birth: - $ vim test $ stat test File: `test' Size: 5 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 152694 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1001/ aaron) Gid: ( 1001/ aaron) Access: 2012-08-21 11:05:52.890021630 +0200 Modify: 2012-08-21 11:06:31.606023626 +0200 Change: 2012-08-21 11:06:31.638023629 +0200 Birth: - $ cat test test $ stat test File: `test' Size: 5 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 152694 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1001/ aaron) Gid: ( 1001/ aaron) Access: 2012-08-21 11:06:44.662024298 +0200 Modify: 2012-08-21 11:06:31.606023626 +0200 Change: 2012-08-21 11:06:31.638023629 +0200 Birth: - $ cat test test $ stat test File: `test' Size: 5 Blocks: 8 IO Block: 4096 regular file Device: 803h/2051d Inode: 152694 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1001/ aaron) Gid: ( 1001/ aaron) Access: 2012-08-21 11:06:44.662024298 +0200 Modify: 2012-08-21 11:06:31.606023626 +0200 Change: 2012-08-21 11:06:31.638023629 +0200 Birth: -
Best Answer
http://en.wikipedia.org/wiki/Stat_(system_call)
Criticism of atime
Writing to a file changes its mtime and ctime, while reading a file changes its atime. As a result, on a POSIX-compliant system, reading a file causes a write, which has been criticized. This behaviour can usually be disabled by adding a mount option in /etc/fstab.
However, turning off atime updating breaks POSIX compliance, and some applications, notably the mutt mail reader (in some configurations), and some file usage watching utilities, notably tmpwatch. In the worst case, not updating atime can cause some backup programs to fail to back up a file.
Linux kernel developer Ingo Molnár called atime "perhaps the most stupid Unix design idea of all times," adding: "[T]hink about this a bit: 'For every file that is read from the disk, lets do a ... write to the disk! And, for every file that is already cached and which we read from the cache ... do a write to the disk!'" He further emphasized the performance impact thus:
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.
how to know if noatime or relatime is default mount option in kernel?
Which is how that particular partition was mounted and why cat does not update the access time as I expected.