wjtx_crossserver/bin/shutdown.sh
aozhiwei 3b15096b51 1
2020-02-01 20:01:07 +08:00

36 lines
697 B
Bash
Executable File

#!/bin/sh
APP_HOME=$(cd $(dirname $0)/..; pwd)
echo "APP_HOME : $APP_HOME"
cd $APP_HOME
PID_FILE="$APP_HOME/logs/app.pid"
echo "PID_FILE : $PID_FILE"
if [ -e $PID_FILE ]; then
count=0
pid=`cat $PID_FILE`
echo "prepare kill pid $pid"
kill -15 $pid
count=`ps -ef | grep $pid | grep -v "grep" | wc -l`
echo "count=$count"
i=1
for(( i=1;i<100;i++))
do
count=`ps -ef | grep $pid | grep -v "grep" | wc -l`
if [ $count -gt 0 ]; then
echo sleep $i second
sleep 1
else
#若进程已经关闭,则跳出循环
echo "break"
rm $PID_FILE
break
fi
done
else
echo "$PID_FILE not exist"
fi