Linux之kill命令(根据进程名批量查杀进程)

Linux之kill命令(根据进程名批量查杀进程)

以查杀curl相关进程为例:

#方法一:
ps -ef | grep "curl" | grep -v grep | awk -F' ' '{print $2}' >  ./fock_chang.txt
while read xx; do echo $xx; kill -9 $xx; done < ./fock_chang.txt
#方法二:
for xx in `ps -ef | grep "curl" | grep -v grep | awk -F' ' '{print $2}'`;do echo $xx;kill -9 $xx; done
#方法三(推荐):
ps -ef | grep "curl" | awk '{print $2}' |xargs kill -9

你可能感兴趣的:(Linux命令)