首页 > 系统相关 >根据进程名杀掉进程

根据进程名杀掉进程

时间:2023-03-22 18:06:11浏览次数:36  
标签:grep 根据 杀掉 kill echo var exit 进程 fi

#!/bin/sh
#add by hudong,2003-08-04
#kill process by program-name
if test $# -lt 1
then
echo "Usage:"$0" program-name"
exit 1
fi

var=`ps -ef|grep $1|grep -v grep |awk '{ printf "%s ", $2}'`

if [ -z "$var" ]
then
echo "$1 not started!"
exit 1
else
if kill -9 $var
then
echo "$1 is killed"
else
echo "$1 is not killed!Please check!"
exit 1
fi
fi


 

标签:grep,根据,杀掉,kill,echo,var,exit,进程,fi
From: https://blog.51cto.com/u_2650279/6143057

相关文章