实时监控练习

[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 %

 

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值