Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On Ubuntu 12.04 I did the following

  1. stat a file
  2. cat the same file
  3. stat the file again
  4. cat the file again after 5 min
  5. stat the file

The access time reported at 3. reflects the point at which 2. was run. However, the access time reported at 5. coincides with 2. and not 4. Is this because Linux serves the file out of cache and avoids disk access in the second instance? Also is there a way to retrieve a list of files that are currently resident in disk cache?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

Caching is transparent. It does not affect a file's metadata. A file's access date shows when the file was read, never mind whether reading the file caused a read from the disk.

By default, Linux does not update file access times. The default mount option sine kernel 2.6.30 is relatime, which sacrifices the usefulness of file access times for a small performance gain. It seems that your filesystem is mounted with the relatime option, so the second read of the file didn't update its atime.

share|improve this answer
    
thank you, relatime is indeed the culprit based on /proc/mounts. –  1_CR Oct 14 '12 at 22:08
add comment

Metadata cache is usually different from file cache. You can get a list of cached files with the fincore utility, see: http://code.google.com/p/linux-ftools/ .

share|improve this answer
1  
@wazook, thanks, +1 for the link to fincore. Working on compiling it. As to your point on metadata cache versus file cache, are you suggesting that output from the stat command in the second case represents stale information from the metadata cache? –  1_CR Oct 14 '12 at 21:50
    
True, but irrelevant here. Caching doesn't influence the file's metadata. –  Gilles Oct 14 '12 at 22:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.