/usr/local/bin
sudo nano .hosts
s101s102s103s104s105
xcall.sh
#!/bin/bashfor host in `cat /usr/local/bin/.hosts` ;do tput setaf 2 echo ======== $host ======== tput setaf 7 ssh $host "source /etc/profile;$@"done
xcall.sh "yum install -y rsync.x86_64"
scp -r /soft/hadoop/etc centos@s104:/soft/hadoop/ 不支持软连接
rsync -lr /soft/hadoop/etc centos@s104:/soft/hadoop/
xsync.sh
#!/bin/bashname=`whoami`# 指定文件所在文件夹名称dir=`dirname $1`# 指定文件的文件名filename=`basename $1`# 进入到dir中cd $dir# 得到当前目录的绝对路径fullpath=`pwd`for((i=102 ; i<=105; i++)) ; do tput setaf 2 echo ==================== s$i $@ =================== tput setaf 9 rsync -lr $filename "$name"@s"$i":$fullpathdone
记得给文件执行权限 chmod 777 xcall.sh