Skip to content
shell
#!/bin/bash
#date:2024年4月8日

APP_NAME=lamp-boot-server-none.jar
LOG_FILE=/opt/code/phi-daily/out.log
PID=$(ps -ef | grep $APP_NAME | grep -v grep | awk '{ print $2 }')
 
if [ -z "$PID" ]
then
    echo "程序未启动。"
else
    echo "程序在启动中,正在停止..."
    kill -9 $PID
fi

echo '开启启动程序 ...'

nohup java -jar -Dspring.profiles.active=prod $APP_NAME > $LOG_FILE 2>&1 &

echo "starting service..."
sleep 20
 
#根据重启后是否有当前应用判断启动是否成功
endPID=$(ps -ef | grep  $APP_NAME | grep -v grep | awk '{ print $2 }')
 
if [ -z "$endPID" ]
then
    echo "程序启动失败。"
else
    echo "程序重启成功...pid:"${endPID}
fi

Last updated:

开发者笔记仓库