shell脚本判断进程是否存在,并重新启动
答案:1 悬赏:40 手机版
解决时间 2021-03-08 19:51
- 提问者网友:辞取
- 2021-03-07 18:57
shell脚本判断进程是否存在,并重新启动
最佳答案
- 五星知识达人网友:几近狂妄
- 2021-03-07 19:47
#!/bin/bash#
#调用关闭jboss进程脚本
stopMethodServer.sh
#打印出当前的jboss进程:grep jboss查询的jboss进程,grep -v grep 去掉grep进程
jmsThread=`ps -ef | grep gdms | grep jboss | grep -v grep`
echo $jmsThread
#查询jboss进程个数:wc -l 返回行数
count=`ps -ef | grep gdms | grep jboss | grep -v grep | wc -l`
echo $countsec=7#开始一个循环,以判断进程是否关闭
for var in 1 2doif [ $count -gt 0 ]; then
#若进程还未关闭,则脚本sleep几秒
echo sleep $sec second the $var time, the JMS thread is still alivesleep $secelse#若进程已经关闭,则跳出循环echo breakbreakfidone
#if [ $count -eq 0 ]; then
# echo nohup startMethodServer.sh &
# nohup startMethodServer.sh &#else# echo It's better to check the thread!!!#fi
#调用启动脚本
#调用关闭jboss进程脚本
stopMethodServer.sh
#打印出当前的jboss进程:grep jboss查询的jboss进程,grep -v grep 去掉grep进程
jmsThread=`ps -ef | grep gdms | grep jboss | grep -v grep`
echo $jmsThread
#查询jboss进程个数:wc -l 返回行数
count=`ps -ef | grep gdms | grep jboss | grep -v grep | wc -l`
echo $countsec=7#开始一个循环,以判断进程是否关闭
for var in 1 2doif [ $count -gt 0 ]; then
#若进程还未关闭,则脚本sleep几秒
echo sleep $sec second the $var time, the JMS thread is still alivesleep $secelse#若进程已经关闭,则跳出循环echo breakbreakfidone
#if [ $count -eq 0 ]; then
# echo nohup startMethodServer.sh &
# nohup startMethodServer.sh &#else# echo It's better to check the thread!!!#fi
#调用启动脚本
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯