SpringBoot啓停腳本(親測可用)

startup.sh

#!/bin/sh
APP_NAME="platform-admin"
JAVA_OPT="-Xmx256m"
#has started
tpid=`ps -ef|grep ${APP_NAME}|grep -v grep|grep -v kill|awk '{print $2}'`
if [[ ${tpid} ]]; then
    echo "error: ${APP_NAME} has started"
   exit 1
fi
rm -f tpid
nohup /opt/jdk1.8.0_25/bin/java ${JAVA_OPT} -jar "${APP_NAME}.jar"  > nohup.out 2>&1 &
echo $! > tpid
echo Start Success!

shutdown.sh

#!/bin/sh
APP_NAME="platform-admin"
tpid=`ps -ef|grep ${APP_NAME}|grep -v grep|grep -v kill|awk '{print $2}'`
if [[ ${tpid} ]]; then
    echo 'Stop Process...'
    kill -15 ${tpid}
else
     echo "error: ${APP_NAME} not found"
     exit 1
fi
sleep 5
tpid=`ps -ef|grep ${APP_NAME}|grep -v grep|grep -v kill|awk '{print $2}'`
if [[ ${tpid} ]]; then
    echo 'Kill Process!'
    kill -9 ${tpid}
else
    echo 'Stop Success!'
fi

 

歡迎各位大神評論點贊!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章