1 [root@nfs-server tools]# tar zxf inotify-tools-3.14.tar.gz
2 [root@nfs-server tools]# cd inotify-tools-3.14
3 [root@nfs-server inotify-tools-3.14]# ./configure --prefix=/usr/local/inotify-tools-3.14
4 [root@nfs-server inotify-tools-3.14]# make&&make install
1 [root@nfs-server inotify-tools-3.14]# ln -s /usr/local/inotify-tools-3.14/ /usr/local/inotify-tools ##创建软链接 2 [root@nfs-server inotify-tools-3.14]# cd .. 3 [root@nfs-server local]# ll 4 total 44 5 drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin 6 drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc 7 drwxr-xr-x. 2 root root 4096 Sep 23 2011 games 8 drwxr-xr-x. 2 root root 4096 Sep 23 2011 include 9 lrwxrwxrwx. 1 root root 30 Jan 31 01:58 inotify-tools -> /usr/local/inotify-tools-3.14/ 10 drwxr-xr-x. 6 root root 4096 Jan 31 01:55 inotify-tools-3.14 11 drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib 12 drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64 13 drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec 14 drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin 15 drwxr-xr-x. 5 root root 4096 Nov 25 02:40 share 16 drwxr-xr-x. 2 root root 4096 Sep 23 2011 src 17 [root@nfs-server local]# cd inotify-tools 18 [root@nfs-server inotify-tools]# ll 19 total 16
提示编译成功后会生成4个目录,分别是:
1 [root@nfs-server /]# cd /usr/local/inotify-tools 2 [root@nfs-server inotify-tools]# ll 3 total 16 4 drwxr-xr-x. 2 root root 4096 Jan 31 01:55 bin ##inotify执行命令(二进制) 5 drwxr-xr-x. 3 root root 4096 Jan 31 01:55 include ##inotify程序所需用的头文件 6 drwxr-xr-x. 2 root root 4096 Jan 31 01:55 lib ##动态链接的库文件 7 drwxr-xr-x. 4 root root 4096 Jan 31 01:55 share ##帮助文档
工具集合介绍:
一共安装了2个工具(命令),即inotifywait和inotifywatch
inotifywait:在被监控的文件或目录上等待特定文件系统事件(open、close、delete等)发生,执行后处于阻塞状态,适合在shell脚本中使用。
inotifywatch:收集被监视的文件系统使用度统计数据,指定文件系统事件发生的次数统计。
4)inotify命令常用参数详解
1 [root@nfs-server inotify-tools]# ./bin/inotifywait --help 2 inotifywait 3.14 3 Wait for a particular event on a file or set of files. 4 Usage: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ ... ] 5 Options: 6 -r|--recursive Watch directories recursively. ##递归查询目录 7 -q|--quiet Print less (only print events) ##打印很少的信息,仅仅打印监控相关的信息 8 -m|--monitor Keep listening for events forever. Without 9 this option, inotifywait will exit after one 10 event is received. ##始终保持事件监听状态 11 --excludei <pattern> 12 Like --exclude but case insensitive. ##排除文件或目录时,不区分大小写 13 --timefmt <fmt> strftime-compatible format string for use with 14 %T in --format string. ##指定时间的输出格式