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

 

欢迎各位大神评论点赞!

作者:没有梦想何必远方#

相关推荐

Django 用户认证(Auth)组件

Django 用户认证(Auth)组件

Django cookie 与 session

Django cookie 与 session

Django 中间件

Django ORM – 多表实例

Django ORM – 多表实例