如何查找SHELL的進程號並殺死

1、shell查找進程並殺死linux

#!/bin/sh

tomcat_id=`ps -ef | grep tomcat | grep -v "grep" | awk '{print $2}'`
echo $tomcat_id

for id in $tomcat_id
do
    kill -9 $id  
    echo "killed $id"  
done

注意:tomcat表示要查找的程序進程名,如:tomcat、8081端口、redis等等。redis

2、linux查找進程並殺死shell

#####查找tomcat進程
ps -ef | grep tomcat | grep -v grep | awk '{print $2}'
#####查找tomcat進程並殺死
ps -ef | grep tomcat | grep -v grep | awk '{print $2}' | xargs kill -9
 
相關文章
相關標籤/搜索