Best way to monitor file system changes in linux

那年仲夏 提交于 2019-11-28 05:55:05

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.

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.

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