shutdown.sh 450 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. app_name='devops-agent.jar'
  3. pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2`
  4. echo "process id: "${pid}
  5. if [[ -z ${pid} ]];
  6. then
  7. echo "process killed"
  8. else
  9. kill -15 ${pid}
  10. fi
  11. echo "sleep 10s and wait process killed"
  12. sleep 10
  13. pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2`
  14. if [[ -z ${pid} ]];
  15. then
  16. echo "${app_name} has killed"
  17. else
  18. echo "process ${pid} not killed"
  19. fi