国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

expect自動檢測并重啟另外一臺服務器上的程序代碼

2019-10-26 18:35:53
字體:
來源:轉載
供稿:網友

[s005 you] # cat haproxy_expect
代碼如下:
#!/usr/bin/expect
set ssh_user "fivetrees"
set password "123456"
spawn ssh -i /root/.ssh/$ssh_user Server004.xd.com
expect_before "no)?" {
send "yes/r" }
sleep 0.5
expect "Enter passphrase for key*"
send "$password/r"
expect "*#"
send "/tmp/haproxy.sh/r"
expect "*#"
send "echo/r"
exit

[s004 him] # cat haproxy.sh

代碼如下:
#!/bin/bash
Thread=`ps -ef | grep haproxy | grep -v haproxy.sh | grep -v grep`
if [ -z "$Thread" ]
then
        /tmp/haproxy_expect
fi

[s004 him] # cat haproxy_expect

代碼如下:
#!/usr/bin/expect
set ssh_user "fivetrees"
set password "123456"
spawn ssh -i /root/.ssh/$ssh_user Server005.xd.com
expect_before "no)?" {
send "yes/r" }
sleep 0.5
expect "Enter passphrase for key*"
send "$password/r"
expect "*#"
send "/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg/r"
expect "*#"
send "echo/r"
exit

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太保市| 上杭县| 河北省| 乡宁县| 高雄县| 辰溪县| 鄢陵县| 彰化县| 桓台县| 龙川县| 济源市| 灵山县| 南江县| 丹阳市| 乌审旗| 乌拉特中旗| 抚远县| 富平县| 青浦区| 兴国县| 阿巴嘎旗| 塘沽区| 确山县| 襄汾县| 高密市| 乐业县| 双桥区| 阿拉尔市| 芒康县| 武山县| 巧家县| 洛扎县| 上杭县| 城固县| 鸡西市| 凉山| 茶陵县| 句容市| 博兴县| 丹巴县| 北票市|