Quantcast
Channel: 容器云计算,Devops,DBA,网络安全。
Viewing all articles
Browse latest Browse all 780

Linux 按名称查找某个进程并关闭

$
0
0

Linux 按名称查找某个进程并关闭。

参考一下,水平有限。

! /bin/sh  

 

ID=`ps -ef| grep 'ntpd'|grep -v 'grep'|awk '{print $2}'` 

if [ "$ID" = "" ]  
then  
  echo "ID is not  running!"  
else    
for pid in $ID 

do  

kill -9 $pid  

echo " kill ntpd pid:$pid"

fi  


Viewing all articles
Browse latest Browse all 780