Linux: don’t use file system cache under a directory

filesfilesystemslinuxmount

For a PHP website I'm monitoring, I need to see what files are being used each time the browser makes a request.

I thought of using find . -type f -amin 1.
With that I get all files which were read in the last minute (it's a developing server so only I am using the website).

I took care of removing the noatime attribute from the mounting point.
However there must be something else that's preventing the kernel from reading the actual files on disk because the access time is not being updated when I read a file.
I guess it must be the file-system cache which is retrieving the files from memory.

Is there a way to disable file caching under a specific directory? (public_html in my case)

Also I read somewhere that there is the nobh mounting atributes which apparently disables file caching under that mounting point, but I'm not sure.

Best Answer

Why not look at the apache logs? It lists each file that gets accessed with a timestamp as well as who accessed it.

If you must use atime, note the following from wikipedia page on stat system call:

Linux kernel developer Ingo Molnár called atime "perhaps the most stupid Unix design idea of all times," adding: "Think about this a bit: 'For every file that is read from the disk, let's 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 I/O 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.

Current versions of Linux support four mount options, which can be specified in fstab:

strictatime (formerly atime, and formerly the default; strictatime as of 2.6.30) – always update atime
relatime ("relative atime", introduced in 2.6.20 and the default as of 2.6.30) – only update atime under certain circumstances (explained below)
nodiratime – never update atime of directories, but do update atime of other files
noatime – never update atime of any file or directory; implies nodiratime; highest performance, but least compatible
Related Topic