安装inotify
[root@b ~]# yum -y install inotify-tools
编写脚本
[root@b ~]# vim inofity.sh
添加权限
[root@b ~]# chmod 700 inofity.sh
执行脚本
[root@b ~]# ./inofity.sh
在另一个终端执行删除指令
[root@b ~]# rm -rf /app/studentweb/今天星期四
查看日志
[root@b ~]# cat /var/log/rsync.log
2024-07-18 17:24:26出现事件/app/studentweb/ DELETE 今天星期四
执行脚本
[root@b ~]# ./inofity.sh
另一个终端创建文件
[root@b ~]# touch /app/studentweb/明天就是周五啦
[root@b ~]# touch /app/studentweb/明天就是周五啦
重新查看日志
[root@b ~]# cat /var/log/rsync.log
2024-07-18 17:24:26出现事件/app/studentweb/ DELETE 今天星期四
2024-07-18 17:30:20出现事件/app/studentweb/ ATTRIB 明天就是周五啦
2024-07-18 17:30:31出现事件/app/studentweb/ ATTRIB 明天就是周五啦