Qkill

QKill是基于pskill -9 的sh脚本 , 用于快速杀死具有某个关键词的PID

#!/bin/zsh

name=$1
user="$USER"
flag=0

if [[ $# = 2 && $2 -eq 1 ]];then
	flag=1;	
fi


file=tempPsCheck.txt
if [ $# = 0 ];then
	echo "\033[35;38mDO NOT FIND A VAL\033[0m"
	return
fi

echo $user
if [ $flag -eq 1 ];then
	echo No Show The Ps
fi

echo -e "\033[32;38mthis is a sh for service QUICK STOP\033[0m"
echo -e "\033[32;38mDELETE SERVICE $name\033[0m"

rm -rf $file
touch $file
chmod 700 $file

ps -ef | grep -v "$0" | grep $name > $file

if [ $flag -eq 1 ];then
	cat $file
fi

wait

awk '{print $2}' $file | xargs -I {} kill -9 {}

wait

rm -rf $file

echo Finish!
文章作者: cosh
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 cosh'blog
脚本
喜欢就支持一下吧