sync 同步脚本

使用inotifywait 自动同步所有修改的文件和目录:

#!/bin/sh

srcdir=/www/aaa/backend/web/upload/mapped/
dstdir=/kolla/aaa/.notebook/

dstip="192.168.25.112  192.168.25.113"

mkdir -p $srcdir
chown -R www:www $srcdir

for ip in $dstip
do
ssh $ip "mkdir -p $dstdir"
rsync -avH --progress --delete $srcdir $ip:$dstdir
done

/usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,modify,delete,create,attrib,move $srcdir | while read file
do
for ip in $dstip
do
rsync -avH --progress --delete $srcdir $ip:$dstdir
echo " ${file} was rsynced..." >> /var/log/rsync_jupyter.log 2>&1
done
done


你可能感兴趣的:(sync 同步脚本)