手机
当前位置:查字典教程网 >脚本专栏 >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自动检测并重启另外一台服务器上的程序代码】相关文章:

查找目录下同名但不同后缀名文件的shell脚本代码

Shell脚本中调用、引用、包含另外一个脚本文件的两种方法

shell遍历目录处理特定目录的脚本代码

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

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

Shell中调用、引用、包含另一个脚本文件的三种方法

linux shell txt转换成html的实现代码

自动化下载并检测ftp文件备份的shell脚本

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

linux服务器安全加固shell脚本代码

精品推荐
分类导航