jar包项目启动脚本
程序员文章站
2022-05-11 13:23:36
...
RESOURCE_NAME后面接的是jar包名称,jar包后缀名使用.sh
#!/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!
上一篇: H5标签
下一篇: 实现简单的进度条效果