Process Check 스크립트
------------------------------------------------------------------------------
#!/bin/bash
export SERVER_PATH="/root"
if [ ! -e "mongo-start.pid" ];
then
echo "mongo-start"
process_chk='ps -ef | grep -v "grep"|grep mongod| wc -l'
no_process="0"
if [ "$process_chk" == "$no_process" ];
then
echo "start mongo"
cd $SERVER_PATH; sh ./mongo_start.sh
fi
fi
if [ -e "mongo-start.pid" ];
then
echo "start.pid"
process_chk='ps -ef | grep -v "grep"|grep mongod| wc -l'
no_process="0"
if [ "$process_chk" == "$no_process" ];
then
echo "start mongo"
rm $SERVER_PATH/mongo-start.pid
cd $SERVER_PATH; sh ./mongo_start.sh
fi
fi
------------------------------------------------------------------------------------
Process 실행, pid 파일 생성 스크립트
------------------------------------------------------------------------------------
#!/bin/bash
echo "mongo start"
nohup mongod --auth --config /etc/mongod.conf &
export SEVERPID=$!
cd ~/
echo ${SEVERPID} | cat > mongo-start.pid
echo "mongo start end"
------------------------------------------------------------------------------------
참조 : https://limdh3325.blogspot.com/2021/04/pid.html
댓글
댓글 쓰기