1. 程式人生 > >rsync+inotify-tools進行同步文件

rsync+inotify-tools進行同步文件

同步 innotify rsync

參考 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可以用源碼包安裝;

rsync+inotify-tools進行同步文件