定时清理僵尸进程

之前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 defunctawk '{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

定时清理僵尸进程
https://occdn.limour.top/2448.html
Author
Limour
Posted on
October 27, 2022
Licensed under