用shell通过jps -m来杀死进程


  1. #!/bin/sh
  2. ### find pid
  3. jps=`jps -m`
  4. echo "$jps"|while read i
  5. do
  6. if[[ $i =~"agentTestTopic"]];
  7. then
  8. #将字符串分割成数组
  9. OLD_IFS="$IFS"
  10. IFS=" "
  11. arr=($i)
  12. IFS="$OLD_IFS"
  13. echo ${arr[0]}
  14. pid=${arr[0]}
  15. kill -9 $pid
  16. fi
  17. done
  18.  
  19. echo "agentTestTopic is stoped"
posted @ 2017-09-20 11:35  四叶草Grass  阅读(961)  评论(0编辑  收藏  举报