#!/bin/sh JAR_NAME=material.jar tpid=`ps -ef|grep $JAR_NAME|grep -v grep|grep -v kill|awk ‘{print $2}‘` if [ ${tpid} ]; then echo ‘Stop Process...‘ fi sleep 5 tpid=`ps -ef|grep $JAR_NAME|grep -v grep|grep -v kill|awk ‘{print $2}‘` if [ ${tpid} ]; then echo ‘Kill Process!‘ kill -9 $tpid else echo ‘Stop Success!‘ fi tpid=`ps -ef|grep $JAR_NAME|grep -v grep|grep -v kill|awk ‘{print $2}‘` if [ ${tpid} ]; then echo ‘App is running.‘ else echo ‘App is NOT running.‘ fi rm -f tpid # nohup java -jar ./$JAR_NAME --spring.profiles.active=test >/dev/null 2>&1 & nohup java -jar /home/javaweb/matrial/$JAR_NAME >/home/javaweb/matrial/mat.log 2>&1 & echo $! > tpid echo ‘Start Success!‘
原文:https://www.cnblogs.com/HHR-SUN/p/14554273.html