首先,后台每隔一段时间:
# !/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