追风中的小少年 2021-11-25 13:59 采纳率: 82.4%
浏览 30
已结题

第一次使用linux启动springboot的jar包,想写个shell脚本,网上的大都不详细

第一次使用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!'
    fi

    rm -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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 12月15日
  • 已采纳回答 12月7日
  • 创建了问题 11月25日