首页 > 代码库 > linux批量复制文件到多台服务器脚本

linux批量复制文件到多台服务器脚本

=======================xsync.sh======================================

#!/bin/bash


if [[ $# -lt 1 ]] ; then echo no params ; exit ; fi

p=$1

#echo p=$p

dir=`dirname $p`

#echo dir=$dir

filename=`basename $p`

#echo filename=$filename

cd $dir

fullpath=`pwd -p . `

#echo fullpath=$fullpath


user=`whoami`

for((i=202;i<=206;i=$i+1));do

  echo ==========s$i============

rsync -lr $p ${user}@s$i:$fullpath

done ;






#!/bin/bash

if [[ $# -lt 1 ]] ; then echo no params ; exit ; fi

p=$1

dir=`dirname $p`

filename=`basename $p`

cd $dir

fullpath=`pwd -P . `

echo $fullpath


hosts=`cat /usr/local/bin/slaves`

for host in $hosts; do

  echo ========== $host ============

  rsync -lr $p ${user}@$host:$fullpath

done ;


linux批量复制文件到多台服务器脚本