监控Linux中文件系统变化的最佳方法

发布于 2024-12-19 10:26:15 字数 395 浏览 2 评论 0原文

我正在考虑构建一个文件系统同步实用程序来监视文件系统活动,但似乎 Linux 内核中的某些文件系统监视功能已过时或功能不完整。

我的研究发现

dnotify 首先带有通知,具有通知删除、修改、访问、属性、创建、移动的功能,可以确定文件描述符,但是现在已经过时了 inotify 和 fanotify

inotify 第二位带有通知,具有这些功能通知访问、修改、属性、关闭、移动、删除、创建等,但它不会为您提供文件描述符或进程,并且将被 fanotify 过时

fanotify 是通知访问的最新版本,修改,关闭,但不通知删除或属性,但提供文件描述符

我需要一种确定进程(例如从fd)和删除,修改,属性等的方法,以便同步所有内容,有什么建议吗?不幸的是 dnotify 似乎是最好的但也是最过时的

I'm looking at building a file system sync utility that monitors file system activity, but it appears that some of the file system monitoring features in the linux kernel are obsolete or not fully featured.

What my research as found

dnotify came first with notification has the features of notifying for delete,modify,access,attribs,create,move can determine file descriptor, however is now out dated by inotify and fanotify

inotify came out second with notification has the features of notifying access, modify, attrib, close, move, delete, create, etc however it does not give you a file descriptor or process and will be outdated by fanotify

fanotify is the latest which informs of access, modify, close, but does not inform of delete or attribs, but does provide file descriptor

I need a way of determining the process (e.g. from fd) and things like delete, modify, attribs, etc in order to sync everything, any suggestions? Unfortunately dnotify seems the best but most out-dated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

摘星┃星的人 2024-12-26 10:26:15

您应该使用库而不是 inotify 和朋友 - 类似于 FAM< /a> 或 Gamin (两者的 API 相同)。这将使您的程序可以移植到其他 Unix。

You should use a library instead of inotify and friends - something like FAM or Gamin (it's the same API for both). This will make your program portable to other Unixes.

随波逐流 2024-12-26 10:26:15

有一个很好的库,提供文件描述符或带有 inotify 的进程。它有自己的 C API 和 inotifywatch util(适用于脚本),全部位于 inotify-tools 包中。

我强烈不同意 fanotify 会过时 inotify。

FAM 和 gamin 是非常好的服务器/客户端选项。他们都使用 inotify 作为过时的 dnotify 和 polls 的首选。我更喜欢加明。

There's a good lib providing file descriptors or process with inotify. It has his own C API and the inotifywatch util (good for scripts), all in inotify-tools package.

I strongly disagree that fanotify will outdate inotify.

FAM and gamin are very good server/client options. Both of them use inotify as first option over the outdated dnotify and polls. I prefer gamin.

如此安好 2024-12-26 10:26:15

incron 对于此类操作来说是一个有用的工具。您可以为要监视的目录或文件创建配置文件。

http://inotify.aiken.cz/?section=incron&page =about&lang=en

在 ubuntu

sudo apt-get install incron

/etc/incron.d/mynotification.conf

# notification for user creation
/home IN_ALL_EVENTS /opt/notify_user_created.sh $#

incron is a useful tool for the operations like this. You may create a configuration file for the directory or file that you want to watch.

http://inotify.aiken.cz/?section=incron&page=about&lang=en

in ubuntu

sudo apt-get install incron

/etc/incron.d/mynotification.conf

# notification for user creation
/home IN_ALL_EVENTS /opt/notify_user_created.sh $#
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文