Shell实现判断进程是否存在并重新启动脚本分享
简洁版:
#!/bin/bash
#authorcaoxin
#time2012-10-10
#program:判断进行是否存在,并重新启动
functioncheck(){
count=`ps-ef|grep$1|grep-v"grep"|wc-l`
#echo$count
if[0==$count];then
nohuppython/runscript/working/$1&
fi
}
checkbehaviors.py
详细版:
#!/bin/bash # #调用关闭jboss进程脚本 stopMethodServer.sh #打印出当前的jboss进程:grepjboss查询的jboss进程,grep-v"grep"去掉grep进程 jmsThread=`ps-ef|grepgdms|grepjboss|grep-v"grep"` echo$jmsThread #查询jboss进程个数:wc-l返回行数 count=`ps-ef|grepgdms|grepjboss|grep-v"grep"|wc-l` echo$count sec=7 #开始一个循环,以判断进程是否关闭 forvarin12 do if[$count-gt0];then #若进程还未关闭,则脚本sleep几秒 echosleep$secsecondthe$vartime,theJMSthreadisstillalive sleep$sec else #若进程已经关闭,则跳出循环 echo"break" break fi done #if[$count-eq0];then #echo"nohupstartMethodServer.sh&" #nohupstartMethodServer.sh& #else #echo"It'sbettertocheckthethread!!!" #fi #调用启动脚本 nohupstartMethodServer.sh&
热门推荐
10 升职祝福语简短霸气押韵
11 酒仙网红包祝福语简短
12 侄儿高考试祝福语简短
13 给弟弟敬茶祝福语简短
14 预祝中秋简短的祝福语
15 学弟英语高考祝福语简短
16 同学贺卡励志祝福语简短
17 买车新年祝福语简短创意
18 爸爸生日简单祝福语简短