在 Ubuntu(及其他 Linux 发行版)中,查看**僵尸进程(Zombie / defunct 进程)**常用以下命令:
ps 查看僵尸进程ps aux | grep Z
或更准确地看进程状态为 Z 的:
ps -eo pid,ppid,stat,cmd | awk '$3=="Z"'
解释:
STAT 为 Z 表示僵尸进程PPID 是父进程 IDtop / htoptop
在 top 中:
S 列是否为 Zzombie 数量(右上角)更直观:
htop
(htop 中僵尸进程通常显示为灰色或 Z)
ps aux | awk '$8=="Z" {print $2}' | wc -l
或:
grep zombies /proc/stat
ps -eo pid,ppid,stat,cmd | awk '$3=="Z"'
拿到 PPID 后:
ps -p <PPID> -o pid,cmd
pstree 查看pstree -p | grep defunct
kill -9 PPID)wait())如果你愿意,我可以帮你: