清除指定名称的进程

#!/bin/sh  
TOM_HOME=$1 
ps -ef|grep $TOM_HOME|grep -v grep|grep -v kill  
if [ $? -eq 0 ];then  
kill -9 `ps -ef|grep $TOM_HOME|grep -v grep|grep -v kill|awk '{print $2}'`  
else  
echo $TOM_HOME' No Found Process'  
fi 

  使用时,保存成文件,比如killps.sh 。然后killps 进程名即可

#!/bin/sh TOM_HOME=$1 ps -ef|grep $TOM_HOME|grep -v grep|grep -v kill if [ $? -eq 0 ];then kill -9 `ps -ef|grep $TOM_HOME|grep -v grep|grep -v kill|awk '{print $2}'` else echo $TOM_HOME' No Found Process' fi

原文地址:https://www.cnblogs.com/slqt/p/14314495.html