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

首頁 > 開發 > Linux Shell > 正文

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

2020-07-27 19:25:21
字體:
來源:轉載
供稿:網友

[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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 托里县| 上犹县| 郓城县| 巫山县| 同江市| 塘沽区| 铁力市| 宿松县| 修文县| 清水河县| 肇州县| 益阳市| 宜城市| 兴义市| 岑溪市| 荥阳市| 清水河县| 临夏市| 色达县| 闽侯县| 凤翔县| 乌苏市| 辰溪县| 洛扎县| 鄂托克前旗| 荥经县| 根河市| 凤台县| 南充市| 茂名市| 蓬安县| 蒙城县| 苍溪县| 奉新县| 浙江省| 永平县| 绍兴市| 抚州市| 宣城市| 北辰区| 仁布县|