最近,我通过 Windows 资源管理器发现我的 WSL(ZSHELL)消耗了大量 CPU 资源(大约 35%)。
然后我尝试按照如下方式找出并解决这个问题:
~ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Mar28 ? 00:00:00 /init ro
root 3 1 0 Mar28 tty1 00:00:00 /init ro
mbinary 4 3 0 Mar28 tty1 00:00:12 -zsh
mbinary 48 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 66 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 173 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 225 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 431 1 0 09:45 tty1 00:00:00 [awk] <defunct>
root 6845 1 0 09:53 tty2 00:00:00 /init ro
mbinary 6846 6845 0 09:53 tty2 00:00:04 -zsh
mbinary 7419 6846 0 10:03 tty2 00:00:00 python3
mbinary 7455 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7522 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7559 1 0 14:43 tty1 00:00:00 [awk] <defunct>
mbinary 7587 1 0 14:48 tty1 00:00:00 [awk] <defunct>
mbinary 7595 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7604 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7643 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7666 1 97 15:03 tty1 00:00:21 -zsh
mbinary 7670 7666 0 15:03 tty1 00:00:00 [awk] <defunct>
mbinary 7699 4 0 15:03 tty1 00:00:00 ps -ef
➜ ~ sudo kill -9 1
➜ ~ ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Mar28 ? 00:00:00 /init ro
root 3 1 0 Mar28 tty1 00:00:00 /init ro
mbinary 4 3 0 Mar28 tty1 00:00:12 -zsh
mbinary 48 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 66 1 0 Mar28 tty1 00:00:00 [awk] <defunct>
mbinary 173 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 225 1 0 Mar29 tty1 00:00:00 [awk] <defunct>
mbinary 431 1 0 09:45 tty1 00:00:00 [awk] <defunct>
root 6845 1 0 09:53 tty2 00:00:00 /init ro
mbinary 6846 6845 0 09:53 tty2 00:00:04 -zsh
mbinary 7419 6846 0 10:03 tty2 00:00:00 python3
mbinary 7455 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7522 1 0 14:42 tty1 00:00:00 [awk] <defunct>
mbinary 7559 1 0 14:43 tty1 00:00:00 [awk] <defunct>
mbinary 7587 1 0 14:48 tty1 00:00:00 [awk] <defunct>
mbinary 7595 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7604 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7643 1 0 14:49 tty1 00:00:00 [awk] <defunct>
mbinary 7666 1 99 15:03 tty1 00:00:25 -zsh
mbinary 7670 7666 0 15:03 tty1 00:00:00 [awk] <defunct>
mbinary 7712 4 0 15:03 tty1 00:00:00 ps -ef
它不起作用。
我发现awk
使用该命令后出现了僵尸进程z
。
信息:Windows 10:1809 WSL:Ubuntu 1804
答案1
我正在运行 Microsoft Windows 10 Pro (64 位),版本 10.0.18362,但仍然有恶意的 zsh 进程。此功能可终止恶意的 zsh 进程。
killzshs(){ps ax -o pid,command,ppid | grep '.*zsh.*\s1$' | awk '{print $1}' | xargs kill -9}
然后调用killzshs
或将该函数放入您的点文件中。
答案2
此问题已在 Windows 版本 10.0.18362.30 中修复。详细信息这里