红联Linux门户
Linux帮助

linux shell杀进程方法

发布时间:2007-11-12 01:03:50来源:红联作者:Entertr
function kill_process
{
for pid in `cat $1`
do
{
echo "$pid"
kill -9 $pid
}
done

rm -f $1
}

ps aux | grep "cef" | grep -v "grep" | awk '{print $2}' > /tmp/cef.pid
kill_process "/tmp/cef.pid"

ps aux | grep "mas" | grep -v "grep" | awk '{print $2}' > /tmp/mas.pid
kill_process "/tmp/mas.pid"

ps aux | grep "jboss" | grep -v "grep" | awk '{print $2}' > /tmp/jboss.pid
kill_process "/tmp/jboss.pid"

ps aux | grep "snmp" | grep -v "grep" | awk '{print $2}' > /tmp/snmp.pid
kill_process "/tmp/snmp.pid"

ps -a | grep cef | grep -v cef_monitor | grep -v grep | awk '{printf("kill -9 %s\n",$1)}' | sh
ps -a | grep mas | grep -v grep | awk '{printf("kill -9 %s\n",$1)}' | sh
ps -a | grep jboss | grep -v grep | awk '{printf("kill -9 %s\n",$1)}' | sh
ps -a | grep snmp | grep -v grep | awk '{printf("kill -9 %s\n",$1)}' | sh
文章评论

共有 1 条评论

  1. yezhulin1982 于 2007-11-12 10:50:16发表:

    不错,学习了。