1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. #
  3. #
  4. findProcess(){
  5. PROCESS_NAME="pet-identity"
  6. echo $(ps -ef |grep $PROCESS_NAME|grep java| awk '{print $2}')
  7. }
  8. # 查找进程
  9. PID=$(findProcess)
  10. if [ ! $PID ]; then
  11. echo "Process not found !"
  12. exit 0
  13. else
  14. echo "Process ID ${PID}"
  15. fi
  16. echo "Please wait ..."
  17. kill -9 $PID
  18. # 重新查询一次
  19. PID=$(findProcess)
  20. if [ ! $PID ]; then
  21. echo "Process killed success !"
  22. exit 0
  23. else
  24. echo "Process killed fail, please retry ."
  25. fi