Linux 自动重启进程

#!/bin/sh
echo "Current DIR is " $PWD

# ignore signal hup int quit tstp
trap "" 1 2 3 24

 start_server() {
	ulimit -c unlimited
#	export LD_LIBRARY_PATH=`pwd`/deps/capn/libs:$LD_LIBRARY_PATH
#	rm -f *.pid
#	nohup $PWD/comet-server ./icomet.conf &
	nohup $PWD/java -jar LF_S_SignalProc.jar >> ist.log &
}

 kill_server() {
	#ps -aux | grep comet-server | grep -v grep | awk {'print $2'} | xargs kill -2
	ps -aux | grep java | grep -v grep | awk {'print $2'} | xargs kill -2
}

while [ 1 ]
do
	#propserverpid=`ps -ef | grep comet-server | grep -v grep |awk '{print $2}'`
	propserverpid=`ps -ef | grep java | grep -v grep |awk '{print $2}'`
	if [ ! "$propserverpid" ]
 	then
  		echo "propserver is down, now starting ..."
  		start_server
 	fi
	sleep 1
done

#kill_server

 

你可能感兴趣的:(linux)