#! /bin/bash# transferring code and scripts to the Worker node # change the current working directory CD ${Amazoncrawler_home}#读取worker节点ip列表i=0 whileRead Line1 Do#去除空格 line1= ' echo $line 1 | Sed s/[[:space:]]//g ' #若为空则忽略本行if["$line 1" x = x]; Thencontinue fi #若是注释行 ignore Startchar=${line1:0:1} if["$startChar" x = "#" x]; Thencontinue fi #存储至worker_ips数组 worker_ips[$i]=$line 1 ((I++)) done<./conf/system/worker# Read Service list I=0 whileRead Line1 Do#去除空格 line1= ' echo $line 1 | Sed s/[[:space:]]//g ' #若为空则忽略本行if["$line 1" x = x]; Thencontinue fi #若是注释行 ignore Startchar=${line1:0:1} if["$startChar" x = "#" x]; Thencontinue fi #存储至services数组 services[$i]=$line 1 ((I++)) done<./conf/system/servicesworker_ips[0]='59.77.132.28' forWorker_ipinch${worker_ips[*]} DoEcho------------------------------------------echo Copy to${worker_ip}SSH-P A[Email protected]${worker_ip}"(. /etc/profile;mkdir-p ${Amazoncrawler_home}/conf/system) "SCP conf/system/configuration.properties conf/system/chromedriver [Email protected]${worker_ip}:${Amazoncrawler_home}/conf/system forServiceinch${services[*]} DoSSH-P A[Email protected]${worker_ip}"(. /etc/profile;mkdir-p ${Amazoncrawler_home}/sharedstorage/${Service}) "SCP-R sharedstorage/${Service}/*.jar [Email protected]${worker_ip}:${Amazoncrawler_home}/sharedstorage/${Service}SCP-R sharedstorage/${Service}/*.sh [Email protected]${worker_ip}:${Amazoncrawler_home}/sharedstorage/${Service}Done SCP-R sharedstorage/*.sh [email protected]${worker_ip}:${Amazoncrawler_home}/Sharedstoragedone
Multi-server Sync time
# !/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 ' " = "# scripts for remote server execution locally via SSH Span style= "color: #0000ff;" >for IP in ${ip_array[* do ssh -t-p $port $user @ $ip $cmd done
Linux file Remote transfer client shell script vs. distributed client time synchronization scripts