JAVA,jar包启动、关闭sh脚本

        现在有一SpringBoot项目,该项目制作成的jar包名为: springboot-learning-0.0.1-SNAPSHOT.jar.jar . 将该jar包部署到Linux平台的 /app/dev/springboo-learning 目录下。

 

其启动 start.sh 脚本命令如下:


#!/bin/sh
rm -f tpid
nohup java -Xms256m -Xmx256m -jar /app/dev/springboo-learning/springboot-learning-0.0.1-SNAPSHOT.jar > log-springboot-learning.log 2>&1 &
echo $! > tpid
echo Start Success!
tail -f log-springboot-learning.log

 

其关闭 shutdown.sh 脚本命令如下:


#!/bin/sh
APP_NAME=/app/dev/springboo-learning/springboot-learning-0.0.1-SNAPSHOT.jar

tpid=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
    echo 'Stop Process...'
    kill -15 $tpid
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

 

 

 

你可能感兴趣的:(IT之旅,Java求学路,运维)