zywinner168 发表于 2017-3-1 11:17:53

求救

你好军哥想远程启动但是用ssh后发现nginx进程没有起来,请问怎么远程启动nginx啊?用ssh的方式的话
我现在的格式是
/usr/bin/expect /opt/tools/bin/expect/autossh 192.168.0.188 40023 root abcd1234a/ '/bin/sh /usr/local/nginx/conf/restart.sh restart'

expect 脚本

#!/usr/bin/expect -d
set ip
set port
set username
set password
set remocommand
set timeout -1
spawn /usr/bin/ssh -p $port $username@$ip "$remocommand"
expect {
"*yes/no" { send "yes\r"; exp_continue}
"*password:" { send "$password\r" }
}
interact


restart脚本

#!/bin/bash
action=$1
chown -R www:www /home/wwwroot/moviecms
kill -9 $(ps -ef|grep nginx|awk '{print $2}')
lnmp $1

#!/bin/bash
action=$1
chown -R www:www /home/wwwroot/moviecms
chown -R www:www /home/wwwroot/movietest/
kill -9 $(ps -ef|grep nginx|awk '{print $2}')
lnmp $1

licess 发表于 2017-3-1 19:23:26

nginx有专门的脚本 /etc/init.d/nginx 负责状态管理 https://lnmp.org/faq/lnmp-status-manager.html

zywinner168 发表于 2017-3-2 17:21:34

谢了军哥,搞好了。。。。。
页: [1]
查看完整版本: 求救