xsync

发布时间 2023-10-13 18:01:13作者: Bre-eZe

xsync

#!/bin/bash

if [ $# -lt 1 ]
then 
        echo NOT Enough Argument
        exit;
fi

for host in hadoop100 hadoop101 hadoop102
do
        for file in $@
        do
                if [ -e $file ]
                        then
                                pdir=$(cd -P $(dirname $file);pwd)
                                fname=$(basename $file)
                                ssh $host "mkdir -p $pdir"
                                rsync -av $pdir/$fname $host:$pdir
                        else
                                echo $file does not exists!
                fi
        done
done

将xsync脚本写在环境变量中,赋予777权限
就可以使用
xsync a.txt
xsync a.txt b.txt
xsync /root/a.txt b.txt