linux下的根据项目名称,进行进程的启停脚本
#!/bin/bashJAVA=/usr/bin/java
APP_HOME=/opt/program/qa/wechat
APP_NAME=programname.jar
APP_PARAM="--spring.config.location=${APP_HOME}/application.properties --logging.path=${APP_HOME}"case $1 in
start)
PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
if [ -z "$PID" ] ;thenecho "start ${APP_NAME}"nohup ${JAVA} -Dfile.encoding=utf-8 -jar ${APP_HOME}/${APP_NAME} ${APP_PARAM} > /dev/null 2>&1 &
elseecho "${APP_NAME} is running"
fi
;;stop)
PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
if [ -z "$PID" ] ;thenecho "${APP_NAME} is not running"
elseecho "stop ${APP_NAME}"kill -9 $PID
fi
;;restart)
PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
if [ -z "$PID" ] ;thenecho "start ${APP_NAME}"nohup ${JAVA} -Dfile.encoding=utf-8 -jar ${APP_HOME}/${APP_NAME} ${APP_PARAM} > /dev/null 2>&1 &
elseecho "stop ${APP_NAME}"kill -9 $PIDecho "start ${APP_NAME}"nohup ${JAVA} -Dfile.encoding=utf-8 -jar ${APP_HOME}/${APP_NAME} ${APP_PARAM} > /dev/null 2>&1 &
fi
;;logs)
tail -f ${APP_HOME}/catalina.out
;;status)
PID=$(ps -ef | grep ${APP_NAME} | grep -v grep | awk '{print $2}')
if [ -z "$PID" ] ;thenecho "${APP_NAME} is not running"
elseecho "${APP_NAME} is running, pid $PID"
fi
;;esac