根据进程名强行删除进程

#!/bin/bash

echo "pid_kill进程名:$1"
PROC_NAME=$1
ProcNumber=`ps -ef |grep -w $PROC_NAME|grep -v grep|wc -l`
if [ $ProcNumber -le 0 ];then
   echo "$PROC_NAME is not run"
else
   echo "$PROC_NAME is  running.."
   echo "ps -ef | grep $PROC_NAME |grep -v 'grep'| awk '{print $2}' |while read pid; do kill -9 $pid; done"
   ps -ef | grep $PROC_NAME |grep -v 'grep'| awk '{print $2}' |while read pid; do kill -9 $pid; done
fi

 

posted @ 2021-08-27 23:49  年轻人——001  阅读(98)  评论(0编辑  收藏  举报