ps aux | grep 'Z'
,篩選狀態為Z的進程。pgrep -f 'Z'
。/var/log/syslog
或dmesg
,排查僵尸進程相關錯誤信息。#!/bin/bash
ZOMBIES=$(ps aux | grep 'Z' | grep -v grep | wc -l)
if [ $ZOMBIES -gt 5 ]; then # 閾值設為5
echo "警告:發現$ZOMBIES個僵尸進程!" | mail -s "Zombie Process Alert" admin@example.com
fi
通過crontab
設置定時任務(如每5分鐘運行一次)。kill -9
,優先嘗試kill -TERM
。