标签:
#!/bin/bash # 将代码和脚本传送至worker节点 # 改变当前工作目录 cd ${AMAZONCRAWLER_HOME} #读取worker节点ip列表 i=0 while read line1 do #去除空格 line1=`echo $line1 | sed s/[[:space:]]//g` #若为空则忽略本行 if [ "$line1"x = x ]; then continue fi #若是注释行 忽略 startChar=${line1:0:1} if [ "$startChar"x = "#"x ]; then continue fi #存储至worker_ips数组 worker_ips[$i]=$line1 ((i++)) done < ./conf/system/worker #读取service列表 i=0 while read line1 do #去除空格 line1=`echo $line1 | sed s/[[:space:]]//g` #若为空则忽略本行 if [ "$line1"x = x ]; then continue fi #若是注释行 忽略 startChar=${line1:0:1} if [ "$startChar"x = "#"x ]; then continue fi #存储至services数组 services[$i]=$line1 ((i++)) done < ./conf/system/services worker_ips[0]=‘59.77.132.28‘ for worker_ip in ${worker_ips[*]} do echo ------------------------------------------ echo copy to ${worker_ip} ssh -p 22 fzuir@${worker_ip} "(. /etc/profile;mkdir -p ${AMAZONCRAWLER_HOME}/conf/system)" scp conf/system/configuration.properties conf/system/chromedriver fzuir@${worker_ip}:${AMAZONCRAWLER_HOME}/conf/system for service in ${services[*]} do ssh -p 22 fzuir@${worker_ip} "(. /etc/profile;mkdir -p ${AMAZONCRAWLER_HOME}/SharedStorage/${service})" scp -r SharedStorage/${service}/*.jar fzuir@${worker_ip}:${AMAZONCRAWLER_HOME}/SharedStorage/${service} scp -r SharedStorage/${service}/*.sh fzuir@${worker_ip}:${AMAZONCRAWLER_HOME}/SharedStorage/${service} done scp -r SharedStorage/*.sh fzuir@${worker_ip}:${AMAZONCRAWLER_HOME}/SharedStorage done
多服务机同步时间
#!/bin/bash #变量定义 ip_array=("59.77.233.195" "59.77.233.197" "59.77.233.196" "218.193.126.186" "218.193.126.188" "218.193.126.191" "218.193.126.192") user="fzuir" cmd="sudo date -s ‘2016-9-24 16:34:00‘" port="22" #本地通过ssh执行远程服务器的脚本 for ip in ${ip_array[*]} do ssh -t -p $port $user@$ip $cmd done
linux文件远程传输客户端shell脚本与分布式客户机时间同步脚本
标签:
原文地址:http://www.cnblogs.com/zeze/p/5903434.html