File access count in Linux

家住魔仙堡 提交于 2019-12-04 03:17:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!