stop.sh
#!/bin/bash
#jps -l 列出pid和java完整主類名
#jps -v 列出pid和jvm參數
#jps -m 列出應用程序參數
#awk '{print $1}' 獲取第一個參數 也就是pid
for STOPPID in $(jps -lvm |grep 你要停止的服務名 |awk '{print $1}')
do
#if [ -n $string ] 如果string 非空(非0),返回0(true)
if [ -n "${STOPPID}" ]; then
echo stoppid is ${STOPPID}
kill -9 ${STOPPID}
fi
done