簡(jiǎn)潔版:
#! /bin/bash# author caoxin# time 2012-10-10 # program : 判斷進(jìn)行是否存在,并重新啟動(dòng)function check(){ count=`ps -ef |grep $1 |grep -v "grep" |wc -l` #echo $count if [ 0 == $count ];then nohup python /runscript/working/$1 & fi}check behaviors.py
詳細(xì)版:
#!/bin/bash##調(diào)用關(guān)閉jboss進(jìn)程腳本stopMethodServer.sh#打印出當(dāng)前的jboss進(jìn)程:grep jboss查詢的jboss進(jìn)程,grep -v "grep" 去掉grep進(jìn)程jmsThread=`ps -ef | grep gdms | grep jboss | grep -v "grep"`echo $jmsThread#查詢jboss進(jìn)程個(gè)數(shù):wc -l 返回行數(shù)count=`ps -ef | grep gdms | grep jboss | grep -v "grep" | wc -l`echo $countsec=7#開始一個(gè)循環(huán),以判斷進(jìn)程是否關(guān)閉for var in 1 2do if [ $count -gt 0 ]; then #若進(jìn)程還未關(guān)閉,則腳本sleep幾秒 echo sleep $sec second the $var time, the JMS thread is still alive sleep $sec else #若進(jìn)程已經(jīng)關(guān)閉,則跳出循環(huán) echo "break" break fidone#if [ $count -eq 0 ]; then# echo "nohup startMethodServer.sh &"# nohup startMethodServer.sh &#else# echo "It's better to check the thread!!!"#fi#調(diào)用啟動(dòng)腳本nohup startMethodServer.sh &
新聞熱點(diǎn)
疑難解答
圖片精選