2022-10-27-【迁移】定时清理僵尸进程.md 897 B


title: 【迁移】定时清理僵尸进程 urlname: -ding-shi-qing-li-jiang-shi-jin-cheng date: 2022-10-27 00:03:27 index_img: https://api.limour.top/randomImg?d=2022-10-27 00:03:27

tags: 清理

之前Docker搭建ServerStatus给树莓派装了个监控,发现CPU使用率偏高,一看,发现逗逼宝塔面板产生了几万个僵尸进程,只好临时用北洋的青春的脚本来定时清理一下。

#!/bin/bash
zombie_check=`ps -A -o stat,ppid,pid,cmd | grep -e '^[Zz]'`
 
if [ -n "$zombie_check" ];
 then
 echo "Start to handle the zombie!!!!!"
 for i in `ps aux |grep -w Z |grep -v grep |awk '{print $2}'`
 do
 `ps -ef |grep $i |grep defunct|awk '{print "kill -9 " $2 " "$3}'`
 done
else
 echo "There is no zombie !!!!!"
fi
nano kill_zombie.sh
chmod +x kill_zombie.sh
sudo ./kill_zombie.sh
crontab -e
30 * * * * /usr/bin/sudo /home/pi/kill_zombie.sh