用shell通过jps -m来杀死进程
- #!/bin/sh
- ### find pid
- jps=`jps -m`
- echo "$jps"|while read i
- do
- if[[ $i =~"agentTestTopic"]];
- then
- #将字符串分割成数组
- OLD_IFS="$IFS"
- IFS=" "
- arr=($i)
- IFS="$OLD_IFS"
- echo ${arr[0]}
- pid=${arr[0]}
- kill -9 $pid
- fi
- done
- echo "agentTestTopic is stoped"