shell编写java的启动jar包更新启动脚本

#!/bin/bash

. /etc/profile

type java >/dev/null 2>&1 || { echo >&2 "java not found, exit now !"; exit 1; }
type jps >/dev/null 2>&1 || { echo >&2 "jps not found, exit now !"; exit 1; }

# make sure app not running
PID=$(jps -ml | grep oss-server | awk '{print $1}')
if [ ! -z "${PID}" ];then
    echo "stop oss-server ..."
    kill -15 ${PID}
    sleep 3
    PID=$(jps -ml | grep oss-server | awk '{print $1}')
    if [ ! -z "${PID}" ];then
        echo "Kill -9 ${PID} ..."
        kill -9 ${PID}
    fi
fi

cd /data/apps/oss-server
echo "start oss-server ..."
nohup java -Duser.timezone=GMT+08 -XX:+HeapDumpOnOutOfMemoryError -Xms512m -Xmx512m -jar oss-server-1.0.0.RELEASE.jar --server.port=7070 >nohup.log 2>&1 &

sleep 5

PID=$(jps -ml | grep oss-server | awk '{print $1}')
if [ ! -z "${PID}" ];then
    echo "oss-server is running at ${PID} !"
else
    echo "start oss-server failed !"
fi

你可能感兴趣的:(shell编写java的启动jar包更新启动脚本)