linux文件远程传输客户端shell脚本与分布式客户机时间同步脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/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

多服务机同步时间

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/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

  

 

posted @   陈泽泽  阅读(1170)  评论(0编辑  收藏  举报
编辑推荐:
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
阅读排行:
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· DeepSeek 解答了困扰我五年的技术问题。时代确实变了!
· 本地部署DeepSeek后,没有好看的交互界面怎么行!
· 趁着过年的时候手搓了一个低代码框架
· 推荐一个DeepSeek 大模型的免费 API 项目!兼容OpenAI接口!
点击右上角即可分享
微信分享提示