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


一、shell查找進程並殺死

#!/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等等。

二、linux查找進程並殺死

#####查找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
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM