1. 程式人生 > >linux inotifywait 簡單監控目錄與檔案

linux inotifywait 簡單監控目錄與檔案

inotify-tools專案地址: https://github.com/rvoicilas/inotify-tools
inotify-tools下載地址: http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
inotify-tools 安裝方法: https://github.com/rvoicilas/inotify-tools/wiki

簡單例子

inotifywait -mr /home --timefmt '%Y-%m-%d %H:%M:%S' --format '%T %w %f %e'
-e create,modify,attrib,move,delete | while read time path file action; do # do your thing here echo "$time $path $file $action" >> /test.log done

詳細引數與命令詳解自行百度吧~