Linux中的文件访问计数 [英] File access count in Linux

查看:120
本文介绍了Linux中的文件访问计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以有效地确定对特定文件的访问次数以及访问该文件的过程,而无需存储第三方软件的访问信息?我正在寻找基于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?

推荐答案

否,它没有存储.那将是一个非常奇怪的功能.

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.

  • 您可以使用 inotify 编写自己的程序.这是一个相当不错的简介.
  • 另一个选择是使用Linux审计子系统.这样,您将设置规则来告诉内核您要插入哪些文件,之后您将能够检查日志以获取所需的统计信息.这是一个简短的教程.
  • 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.

这篇关于Linux中的文件访问计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆