手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >expect自动检测并重启另外一台服务器上的程序代码
expect自动检测并重启另外一台服务器上的程序代码
摘要:[s005you]#cathaproxy_expect复制代码代码如下:#!/usr/bin/expectsetssh_user"fivet...

[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 "yesr" }

sleep 0.5

expect "Enter passphrase for key*"

send "$passwordr"

expect "*#"

send "/tmp/haproxy.shr"

expect "*#"

send "echor"

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 "yesr" }

sleep 0.5

expect "Enter passphrase for key*"

send "$passwordr"

expect "*#"

send "/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfgr"

expect "*#"

send "echor"

exit

【expect自动检测并重启另外一台服务器上的程序代码】相关文章:

智能监测自动重启Apache服务器的Shell脚本

shell脚本函数:控制颜色、定位、居中显示的代码

VPS自动备份数据库到FTP的脚本代码

一个ping检测告警函数代码

expect中为send语句上加变量的代码

shell脚本编写的俄罗斯方块游戏代码

Ubuntu下定时提交代码到SVN服务器的Shell脚本分享

except自动登录的几段代码分享

linux下自动备份MySQL数据并上传到FTP上的shell脚本

Shell脚本定时备份清除运行系统日志的代码

精品推荐
分类导航