安装 inotify在A服务器.部署了机房上使用root安装
cd /home/
tar -xvf inotify-tools-3.13.tar.gz
文章插图
cd inotify-tools-3.13/
./configure && make && make install
文章插图
inotifywait 命令 格式格式:inotifywait -mrq -e 监控动作 1,监控动作 2 /监控目录 &示例:inotifywait -mrq -e create,delete /filesrc &-m:始终保持事件监听状态-r:递归查询目录-q:只打印监控事件的信息监控动作:modify(内容),create,attrib(权限),move,delete
rsync+inotify实现数据同步使用root操作在部署机房的服务器上操作
cd /home
脚本1:只会同步增加修改的文件,不会同步删除的文件vi rsync.sh
#!/bin/basha="inotifywait -mrq -e create,delete,modify /home/wxq/"b="rsync -avz /home/wxq/ rsync@192.168.10.162:/home/wxq/"$a | while read directory event file #while 判断是否接收到监控记录do$bdone
脚本2:无论是新增还是修改,删除都会同步a="inotifywait -mrq -e create,attrib,move,delete,modify /home/wxq/"b="rsync -avz --delete /home/wxq/ rsync@192.168.10.162:/home/wxq/"$a | while read directory event filedo$bdone
按下 :wq! 即可保存su rsync
我们开始执行脚本bash /home/rsync.sh &//表示在后台执行
文章插图
接下来我们看看效果
文章插图
【linux下rsync的同步】
推荐阅读
- 尖下巴的女人好不好,尖下巴的女人面相分析
- 小天才z7可以登微信吗_小天才z7能不能下载微信
- linux安装达梦数据库8
- 一键上手时下最火AI作画工具
- 从0搭建vue3组件库:Shake抖动组件
- Tomcat 调优之从 Linux 内核源码层面看 Tcp backlog
- 地下城堡3:魂之诗10月9日礼包兑换码是什么
- 附下载链接 HFS局域网分享文件的神器
- Linux 下搭建 Hive 环境
- Flink WordCount入门