sync + inotify 触发本地目录文件同步

1 安装 sync

yum install rsync -y

2 下载安装inotify

wget http://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz

cd intotify-tools-3.14

./config

make && make install

## 安装完毕查看 inotifywait,inotifywath是否已经存在

which inotifywait

/usr/local/bin/inotifywait

which intotifywatch

/usr/local/bin/inotifywatch

3 编写shell

#vim /root/a2b.sh
#!/bin/bash
/usr/local/bin/inotifywait -mrq -e modify,delete,create,attrib,move /home/a|while read files
do
  rsync -r -v --ignore-existing /home/a/ /home/b
done

4 更改脚本权限

chmod 0755 a2b.sh

5 运行shell

nohup sh kejiagaokao_upload.sh

6 测试OK

上传文件1.txt到a目录 ,到b目录查看1.txt同步成功

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值