#!/bin/sh # # SERVICE_HOME="/opt/yunzhi/sgl-v2" LOG="$SERVICE_HOME/logs/nohup.log" JAR=$(ls -lt ${SERVICE_HOME}/*.jar|head -n1|rev|cut -d" " -f1|rev) start() { PID=`ps -ef|grep marketing-v|grep -v grep|awk '{print $2}'` if [[ "$PID" != "" ]]; then echo "" echo "Service is running. pid=$PID" echo "" exit 0 else echo "" echo "Start service ..." echo "FILE: $JAR" nohup java -jar $JAR > $LOG 2>&1 & echo "Start finished" echo "Pls goto $LOG see process status" echo "" fi } stop() { echo "" echo "Stoping service ..." PID=`ps -ef|grep shigongli-|grep -v grep|awk '{print $2}'` if [[ "$PID" != "" ]]; then kill -9 $PID fi # 这个延迟不能去掉 sleep 1s echo "Service is stoped" echo "" } case $1 in "start") start ;; "stop") stop ;; "reload"|"restart") stop start ;; *) echo "Usage: `basename $0` {start|stop|restart}" exit 1 esac