vim ~/rsync.sh
#!/bin/bash step=2 #间隔的秒数,不能大于60 for (( i = 0; i < 60; i=(i+step) )); do $(rsync -arz /home/aml/docker/nginx/web1/html/* /home/aml/docker/nginx/web2/html/ ) sleep $step done exit 0
将脚本加入crontab任务计划
* * * * * sh /root/rsync.sh
至此实现文件2秒执行一次同步
微信扫描下方的二维码阅读本文