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&
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下