#!/bin/sh # # findProcess(){ PROCESS_NAME="pet-identity" echo $(ps -ef |grep $PROCESS_NAME|grep java| awk '{print $2}') } # 查找进程 PID=$(findProcess) if [ ! $PID ]; then echo "Process not found !" exit 0 else echo "Process ID ${PID}" fi echo "Please wait ..." kill -9 $PID # 重新查询一次 PID=$(findProcess) if [ ! $PID ]; then echo "Process killed success !" exit 0 else echo "Process killed fail, please retry ." fi