查找僵尸进程并杀死的小脚本

 


查找僵尸进程并杀死:

[root@linux115 thebook]# cat zombie_process_kill.sh
#!/bin/bash

#this program used to kill the zombie process

 

pro=`ps aux | awk '{print $1":"$2":"$8}'`

for i in $pro
do
   p1=`echo $i | awk -F: '{print $1}'`
   p2=`echo $i | awk -F: '{print $2}'`
   p3=`echo $i | awk -F: '{print $3}'`
  
   if [ "Z" == "$p3" ]
   then
      echo $p1 "---" $p2 "---" $p3
      kill -9 $p2
      echo "It is kill the zombie process $p2 who is belong the $p1....ok"
   else
      :
   fi
done

 

你可能感兴趣的:(shell学习笔记)