首先转一篇介绍内核中inotify的文章:
inotify -- Linux 2.6 内核中的文件系统变化通知机制
http://www.ibm.com/developerworks/cn/linux/l-inotifynew/
然后转一篇关于inotify使用的文章:
inotify之文件系统事件监控使用入门
http://www.verydemo.com/demo_c167_i5727.html
总计 0
-rw-r--r-- 1 root root 0 12-08 05:42 max_queued_events
-rw-r--r-- 1 root root 0 12-08 05:42 max_user_instances
-rw-r--r-- 1 root root 0 12-08 05:42 max_user_watches
/usr/local/nginx/html/ OPEN index.html
/usr/local/nginx/html/ CLOSE_NOWRITE,CLOSE index.html
/usr/local/nginx/html/ OPEN info.php
/usr/local/nginx/html/ CLOSE_NOWRITE,CLOSE info.php
/usr/local/nginx/html/ OPEN info.php
/usr/local/nginx/html/ CLOSE_NOWRITE,CLOSE info.php
/usr/local/nginx/html/ OPEN info.php
/usr/local/nginx/html/ CLOSE_NOWRITE,CLOSE info.php
Establishing watches...
Finished establishing watches, now collecting statistics.
total access modify attrib close_write close_nowrite open moved_from moved_to move_self create delete delete_self filename
2 0 0 0 0 1 1 0 0 0 0 0 0 /usr/local/nginx/html/
Setting up watches. Beware: since -r was given, this may take awhile!
Failed to watch /root/tmp; upper limit on inotify watches reached!
Please increase the amount of inotify watches allowed per user via ` /proc/sys/fs/inotify/max_user_watches'.
Couldn't initialize inotify. Are you running Linux 2.6.13 or later, and was the
CONFIG_INOTIFY option enabled when your kernel was compiled? If so,
something mysterious has gone wrong. Please e-mail rohan@mcgovern.id.au
and mention that you saw this message.
-rw-r--r-- 1 root root 0 12-08 04:48 1
-rw-r--r-- 1 root root 0 12-08 04:48 2
-rw-r--r-- 1 root root 0 12-08 04:48 3
Setting up watches. Beware: since -r was given, this may take a while!
Watches established.
/root/tmp/ OPEN 1
/root/tmp/ CLOSE_NOWRITE,CLOSE 1
Q_OVERFLOW
/root/tmp/ CLOSE_NOWRITE,CLOSE 2
/root/tmp/ OPEN 3
Q_OVERFLOW
本文出自 “无” 博客,请务必保留此出处http://haoyun.blog.51cto.com/2038762/1083267
再转一篇关于inotify使用中丢失事件的文章:
inotify 事件丢失的那点事
http://www.zhouwenyi.com/node/9506
可使用inotify+ssync来自动进行文件同步,相关文章比较多。
inotify+rsync文件同步and sersync部署同步
http://hi.baidu.com/867358162/item/b9089e356ed173d71b969612
http://hi.baidu.com/changzheng2008/item/7779d35b87666b3a33e0a982
修改inotify相关配置:
echo 1638400 > /proc/sys/fs/inotify/max_queued_events
echo 12800 > /proc/sys/fs/inotify/max_user_instances
echo 819200 > /proc/sys/fs/inotify/max_user_watches
其中:
/proc/sys/fs/inotify/max_user_instances:每个用户可创建的inotify实例最大上限数量
/proc/sys/fs/inotify/max_user_watches:每个inotify实例可监听的最大上限数量
/proc/sys/fs/inotify/max_queued_events:对应的inotify实例队列可容纳的最大上限事件数量
如果直接在源代码中修改的话,修改fs/notify/inotify/inotify_user.c文件中的最后
inotify_max_queued_events = 16384;
inotify_max_user_instances = 128;
inotify_max_user_watches = 8192;
三个数值即可。
inotify的实现与fsnotify的设计
http://blog.163.com/jiaxing_wang/blog/static/18661420420121018415965/