自定义远程目录或文件同步脚本xsync.sh

本章来源:http://blog.csdn.net/hblfyla/article/details/79011099

自定义脚本xrsync

----------------------------------
循环复制文件到所有节点的相同目录下
rsync -rvl /root/Download/data/hello.txt root@yla131:/home/root/Download/data
xrsync hello.txt

【/usr/local/bin/xsync.sh】

#!/bin/sh
pcount=$#
if(( pcount<1 )); then
     echo no args;
     exit;
fi

#获取名称
p1=$1;
fname=`basename $p1`;
#echo fname=$fname;

#获取上级目录的绝对路径
pdir=`cd -P $(dirname $p1) ; pwd`
#echo pdir=$pdir ;

#获取当前用户
cuser=`whoami`

#循环
for((host=130;host<134;host=host+1)) ; do
   echo ------------------ yla$host ----------------------
   #echo $pdir/$fname $cuser@yla$host:$pdir
   rsync -rvl $pdir/$fname $cuser@yla$host:$pdir
done


猜你喜欢

转载自blog.csdn.net/hblfyla/article/details/79011099