欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jar包项目启动脚本

程序员文章站 2022-05-11 13:23:36
...
RESOURCE_NAME后面接的是jar包名称,jar包后缀名使用.sh

jar包项目启动脚本

#!/bin/sh
RESOURCE_NAME=redis-chat-0.0.1-SNAPSHOT.jar 
tpid=`ps -ef|grep $RESOURCE_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 $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
echo 'Kill Process!'
kill -9 $tpid
else
    echo 'Stop Success!'
fi 
tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'`
if [ ${tpid} ]; then
    echo 'App is running.'
else
    echo 'App is NOT running.'
fi 
rm -f tpid
#log to nohup.out
nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=dev &
#no log
#nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=dev >> /dev/null 2>&1 &
echo $! > tpid
echo Start Success!
相关标签: 脚本