[root@y ~]# yum -y install inotify-tools\n已加载插件:fastestmirror\nLoading mirror speeds from cached hostfile\nepel/x86_64/metalink | 15 kB 00:00:00 \n * epel: mirrors.huaweicloud.com\nextras | 2.9 kB 00:00:00 \nlocal | 3.6 kB 00:00:00 \nnginx | 2.9 kB 00:00:00 \nos | 3.6 kB 00:00:00 \nsoft | 2.9 kB 00:00:00 \nupdates | 2.9 kB 00:00:00 \n软件包 inotify-tools-3.14-9.el7.x86_64 已安装并且是最新版本\n无须任何处理\n[root@y ~]# inotifywait -rmq /app/studentweb/\n \n第二个窗口\n[root@y ~]# touch /app/studentweb/cc.txt\n 返回第一个窗口\n/app/studentweb/ CREATE cc.txt\n/app/studentweb/ OPEN cc.txt\n/app/studentweb/ ATTRIB cc.txt\n/app/studentweb/ CLOSE_WRITE,CLOSE cc.txt\n 另一台主机\n[root@x ~]# ls /tmp/\ncc.txt\n2.远程实时同步\n[root@y ~]# vim inotifytxt.sh\n#!/bin/bash\n/usr/bin/inotifywait -rmq -e modify,delete,create,attrib,move /app/studentweb | while read events\ndo\n rsync -av /app/studentweb/ root@192.168.1.20:/tmp/\n echo \"'date +%F\\ %T'出现事件$events\" >> /var/log/rsync.log 2>&1\ndone\n[root@y ~]# chmod +x inotifytxt.sh \n[root@y ~]# ./inotifytxt.sh \n 另一个窗口\n[root@y ~]# touch /app/studentweb/dd.txt\n 第一个窗口\nsending incremental file list\n./\ncc.txt\ndd.txt\n\nsent 549 bytes received 63 bytes 58.29 bytes/sec\ntotal size is 0 speedup is 0.00\nsending incremental file list\n\nsent 464 bytes received 18 bytes 41.91 bytes/sec\ntotal size is 0 speedup is 0.00\n 另一台主机\n[root@x ~]# ls /tmp/\ndd.txt\n3.后台运行\n[root@y ~]# nohup ./inotifytxt.sh &\n[root@y ~]# touch /app/studentweb/rr.txt\n 另一台主机\n[root@x ~]# ls /tmp/\nrr.txt \n4.结束后台运行\n[root@y ~]# kill %