准备编译环境
开源软件多使用C/C++语言开发(需要安装gcc、gcc-c++、make等编译工具)
yum -y install gcc gcc-c++ make
1、下载及解包
[root@localhost ~]# yum -y install wget  #安装下载工具
[root@localhost ~]# wget --no-check-certificate https://jaist.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz   #下载软件包
[root@localhost ~]# tar -xf inotify-tools-3.13.tar.gz
[root@localhost ~]# cd inotify-tools-3.13/
2、配置
通过“./configure --help”可查看帮助
典型配置参数:--prefix=安装目录
[root@localhost inotify-tools-3.13]# ./configure --prefix=/usr/local/inotify-tools
[root@localhost inotify-tools-3.13] ls Makefile  #确认结果
3、编译及安装
[root@localhost inotify-tools-3.13]# make           #编译
[root@localhost inotify-tools-3.13]# make install   #安装
4、结果验证
[root@localhost ~]# ls /usr/local/inotify-tools/*
/usr/local/inotify-tools/bin:
inotifywait  inotifywatch
/usr/local/inotify-tools/include:
inotifytools
/usr/local/inotify-tools/lib:
libinotifytools.a   libinotifytools.so    libinotifytools.so.0.4.1
libinotifytools.la  libinotifytools.so.0
/usr/local/inotify-tools/share:
doc  man
[root@localhost ~]# sed -i '$a export PATH=$PATH:/usr/local/inotify-tools/bin/' /etc/profile                                      #增加环境变量
[root@localhost ~]# source /etc/profile     #更新环境变量使其当前生效
[root@localhost ~]# inotifywait --help #查看程序用法
用法
基本用法:
    inotifywait        [选项]        目标文件夹
常用命令选项:
    -m:持续监控(捕获一个事件后不退出)
    -r:  递归监控、包括子目录及文件
    -q: 减少屏幕输出信息
    -e:指定监视的modify、move、create、delete、attrib等事件类别(不加-e默认监控所有类别)
    -qq:没有屏幕输出(静默模式)
案例:持续跟踪指定文件夹的变化
    - 目标文件夹:/opt
    - 当文档出现监视的事件时,会立即给出相应提示
如:
[root@localhost ~]# inotifywait -mrq -e modify,create,delete /opt
