rsync+inotify-tools进行同步文件

参考 http://seanlook.com/2014/12/12/rsync_inotify_setup/

inotify是一种强大的,细粒度的,异步的文件系统事件监控机制,Linux内核从2.6.13开始引入,允许监控程序打开一个独立文件描述符,并针对事件集监控一个或者多个文件,例如打开、关闭、移动/重命名、删除、创建或者改变属性。

Centos6已经支持:
使用ll /proc/sys/fs/inotify命令,是否有以下三条信息输出,如果没有表示不支持

$ ll /proc/sys/fs/inotify
total 0
-rw-r--r-- 1 root root 0 Mar 22 11:53 max_queued_events
-rw-r--r-- 1 root root 0 Mar 22 11:53 max_user_instances
-rw-r--r-- 1 root root 0 Mar 22 10:56 max_user_watches

inotify-tools提供两种工具,一是inotifywait,它是用来监控文件或目录的变化,二是inotifywatch,它是用来统计文件系统访问的次数。

inotify-tools可以用源码包安装;

猜你喜欢

转载自blog.51cto.com/wenxi123/2107592
今日推荐