linux shell守护进程

首先,后台每隔一段时间:

# !/bin/bash

# =====================
# ZhangXin.CN
# [email protected]
# =====================

while : 
do 
	sh 	   ~/Public/controlcenter/daemon.sh
sleep 10 
done 

 检测进程是否存在:

# !/bin/bash

# =====================
# ZhangXin.CN
# [email protected]
# =====================

echo "Current DIR is " $PWD
stillRunning=$(ps -ef |grep "mongo" |grep -v "grep")
if [ "$stillRunning" ]
then
	echo "ControlCenter Service Was Already Started"
else
	echo "Starting ControlCenter Service ..."
	cd ~/Public/controlcenter
	~/Public/controlcenter/start.sh &
fi

 ok

猜你喜欢

转载自qq85609655.iteye.com/blog/2035240