【迁移】定时清理僵尸进程

Last updated on March 19, 2024 pm

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

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/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
1
2
3
4
5
nano kill_zombie.sh
chmod +x kill_zombie.sh
sudo ./kill_zombie.sh
crontab -e
30 * * * * /usr/bin/sudo /home/pi/kill_zombie.sh

【迁移】定时清理僵尸进程
https://hexo.limour.top/-ding-shi-qing-li-jiang-shi-jin-cheng
Author
Limour
Posted on
October 27, 2022
Updated on
March 19, 2024
Licensed under