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

 

欢迎各位大神评论点赞!

发布了18 篇原创文章 · 获赞 28 · 访问量 508

猜你喜欢

转载自blog.csdn.net/xieweikun_7/article/details/105332106