问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/17009980/file-access-count-in-linux