国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 剑河县| 安国市| 永新县| 恩施市| 兴宁市| 郯城县| 武汉市| 丹阳市| 九寨沟县| 木兰县| 托克逊县| 启东市| 大邑县| 三门县| 若羌县| 桑日县| 合水县| 龙里县| 肥西县| 诏安县| 安徽省| 玉门市| 开原市| 黄浦区| 临清市| 渭源县| 军事| 临武县| 东莞市| 杭锦旗| 霞浦县| 和平县| 上犹县| 台山市| 宁明县| 宁化县| 长海县| 电白县| 桃源县| 德江县| 兰州市|