第一次使用linux启动springboot的jar包,想写个shell脚本,网上的大都不详细,谁有详细步骤
1条回答 默认 最新
Dichotomy_ 2021-11-25 14:47关注RESOURCE_NAME=/xxx.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
kill -9 $tpid
else
echo 'Stop Success!'
firm -f tpid
nohup java -Dfile.encoding=utf-8 -jar /xxx/xxx/$RESOURCE_NAME >/dev/null 2>&1 --spring.profiles.active=prod &
echo $! > tpid
echo Start Success!本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报 编辑记录解决 1无用