inotify-tools 监控文件动态
监控文件实时动态
inotify-tools包含了2个工具:
1. inotifywait
inotifywait -mrq --timefmt '%Y/%m/%d-%H:%M:%S' --format '%T %w %f' -e modify,delete,create,move,attrib /root/tmp/
/root/ OPEN,ISDIR
/root/ CLOSE_NOWRITE,CLOSE,ISDIR
/root/ CREATE a.test
/root/ OPEN a.test
/root/ CLOSE_WRITE,CLOSE a.test
/root/ OPEN,ISDIR
/root/ CLOSE_NOWRITE,CLOSE,ISDIR
/root/ OPEN,ISDIR
/root/ CLOSE_NOWRITE,CLOSE,ISDIR
/root/ OPEN,ISDIR
/root/ CLOSE_NOWRITE,CLOSE,ISDIR
/root/ OPEN,ISDIR
/root/ CLOSE_NOWRITE,CLOSE,ISDIR
/root/ OPEN a.test
/root/ CREATE .a.test.swp
/root/ OPEN .a.test.swp
/root/ CREATE .a.test.swx
/root/ OPEN .a.test.swx
/root/ CLOSE_WRITE,CLOSE .a.test.swx
/root/ DELETE .a.test.swx
/root/ CLOSE_WRITE,CLOSE .a.test.swp
/root/ DELETE .a.test.swp
/root/ CREATE .a.test.swp
2.inotifywatch
^Ctotal modify attrib close_write close_nowrite open moved_from moved_to create delete filename
63 6 5 8 8 16 2 2 8 8 /root/
[root@localhost ~]# inotifywatch -r /root
Establishing watches...
Finished establishing watches, now collecting statistics.
^Ctotal access modify attrib close_write close_nowrite open moved_from moved_to create delete filename
41 1 4 4 5 5 10 1 1 5 5 /root/