shell脚本批量杀死进程

使用Ubuntu系统时常会遇到机器卡死的情况(人生最大的痛苦),所有的键都没有用,只好强制关机,我似乎对此已经'乐此不疲了'。

看到又神牛说: 可以在tty里面把相关的进程杀死,之后就正常。(到目前我还没有试过,好奇怪,自从写了这个脚本就再没有遇到死机的情况)

我用的一个脚本就是:

 1 #########################################################################
 2 # File Name: stopproc.sh
 3 # Author: Stomach_ache
 4 # mail: sudaweitong@gmail.com
 5 # Created Time: 2014年05月03日 星期六 15时00分16秒
 6 # Propose: 
 7 #########################################################################
 8 #!/bin/bash
 9 #根据进程名杀死进程
10 if [ $# -lt 1]
11 then
12     echo "缺少参数:procedure_name"
13     exit 1                                                                  
14 fi
15 PROCESS=`ps -ef|grep $1|grep -v grep|grep -v PPID|awk '{print $2}'`
16 for i in $PROCESS
17 do
18         echo "Kill the $1 process [ $i ]"
19         kill -9 $i
20 done
原文地址:https://www.cnblogs.com/Stomach-ache/p/3705170.html