linux shell 查找java进程并杀进程脚本

shutdown.sh

JarName=lishuoboy-***.jar

# 1、查找进程们(注意可能返回多个)
pIdArr=$(ps -ef | grep java | grep ${JarName} | grep "spring.profiles.active" | grep -v "grep" | awk '{print $2}')

# 2、遍历kill进程们
for pId in ${pIdArr}; do
  kill -9 ${pId}
  echo "进程:${pId} 被kill"
done

posted on 2022-10-30 00:38  小石头小祖宗  阅读(115)  评论(0编辑  收藏  举报  来源

导航