批量升级python版本的shell

1.准备一个文件放入所有需要升级的服务器IP:ansible_failed_ip.txt

2.写一个用于在远程执行的脚本:update.sh

1
2
3
4
5
6
7
8
9
10
11
[root@shvpuppet01 scripts] # cat update.sh 
#!/bin/bash
tar  xf  /usr/local/src/Python-2 .7.13.tgz -C  /usr/local/src/
cd  /usr/local/src/Python-2 .7.13 && . /configure
make  &&  make  install
if  [ -f  /usr/bin/python  ]; then
    mv  /usr/bin/python  /usr/bin/python_old2
    cp  /usr/local/src/Python-2 .7.13 /python  /usr/bin/python
else
    cp  /usr/local/src/Python-2 .7.13 /python  /usr/bin/python
fi

3.写一个脚本用于将需要传输的文件发送给远端服务器并执行远程脚本的脚本:update_python.sh

1
2
3
4
5
6
7
8
9
10
11
12
[root@shvpuppet01 scripts] # cat update_python.sh 
#!/bin/bash
for  ip  in  ` cat  ansible_failed_ip.txt`
do
scp  /usr/local/src/Python-2 .7.13.tgz root@$ip: /usr/local/src/
scp  /server/scripts/update .sh root@$ip: /tmp/update .sh
ssh  $ip  "chmod +x /tmp/update.sh"
done
for  ip  in  ` cat  ansible_failed_ip.txt`
do
ssh  $ip  '/tmp/update.sh'
done

4.执行脚本:sh update_python.sh

本文转自激情燃烧的岁月博客51CTO博客,原文链接http://blog.51cto.com/liuzhengwei521/1964266如需转载请自行联系原作者


weilovepan520

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值