Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File access count in Linux

Is there a way how to effectively determine the number of accesses to a specific file and the process which accessed it without storing the access info by a 3rd party software? I'm looking for something built in inside the linux-based operating systems. The date of the last change is pretty obvious but I need information at least on how many times it was accessed since the creation of the file.

Can anyone shed some light on this file accessing information? Is it stored somewhere?

like image 206
Dropout Avatar asked Jun 09 '13 13:06

Dropout


1 Answers

No, it is not stored. That would be a very odd feature.

You can monitor access to a file and count what you need yourself.

  • You can write your own program doing this with inotify. Here is a rather nice introduction.
  • Another option is using Linux audit subsystem. This way you'll set up rules telling the kernel which files are you interrested in, and later you'll be able to check logs to get whichever statistics you need. Here is a short tutorial.
like image 109
kirelagin Avatar answered Oct 14 '22 12:10

kirelagin