脚本如下:
$ cat copy_company.sh #!/bin/bash#官网发布脚本war=$1back_time=`date +"%Y-%m-%d-%H-%M-%S"`ip='10.10.18.2,10.10.18.7'war_ip=`awk 'BEGIN{allip="'$ip'";split(allip,iplist,",");for(i in iplist) print iplist[i]}'`echo ${war_ip}for i in ${war_ip};do ssh $i "cd /data && cp -r www{,-${back_time}};cd /data/www && rm -rf ./*" scp /tmp/${war} $i:/data/www ssh $i "cd /data/www && unzip ${war}" ssh $i "ls -l /data/www"done