ps aux
的输出包含以下内容:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ubuntu 1496 9.1 0.0 0 0 pts/0 Z+ 19:47 0:30 [python] <defunct>
ubuntu 1501 14.6 0.0 0 0 pts/0 Z+ 19:47 0:48 [python] <defunct>
ubuntu 1502 14.8 0.0 0 0 pts/0 Z+ 19:47 0:48 [python] <defunct>
ubuntu 1503 15.1 0.0 0 0 pts/0 Z+ 19:47 0:49 [python] <defunct>
ubuntu 1504 15.4 0.0 0 0 pts/0 Z+ 19:47 0:50 [python] <defunct>
ubuntu 1505 15.8 0.0 0 0 pts/0 Z+ 19:47 0:52 [python] <defunct>
ubuntu 1506 16.0 0.0 0 0 pts/0 Z+ 19:47 0:53 [python] <defunct>
ubuntu 1507 14.1 0.0 0 0 pts/0 Z+ 19:47 0:46 [python] <defunct>
ubuntu 1508 14.3 0.0 0 0 pts/0 Z+ 19:47 0:47 [python] <defunct>
ubuntu 1509 14.4 0.0 0 0 pts/0 Z+ 19:47 0:47 [python] <defunct>
ubuntu 1510 14.6 0.0 0 0 pts/0 Z+ 19:47 0:48 [python] <defunct>
ubuntu 1511 14.9 0.0 0 0 pts/0 Z+ 19:47 0:49 [python] <defunct>
ubuntu 1512 10.7 0.0 0 0 pts/0 Z+ 19:47 0:35 [python] <defunct>
ubuntu 1513 71.3 0.0 0 0 pts/0 Z+ 19:47 3:55 [python] <defunct>
这些是通过多处理产生的一堆进程,它们已经完成并等待父进程加入。他们为什么占用CPU?
如果这只是 ps
的产物,我如何才能准确了解正在使用的 CPU 量?
最佳答案
僵尸进程(即“已停用”的进程)不消耗 CPU:它只是由内核保留,以便父进程可以检索有关它的信息(例如返回状态、资源使用情况等...) .
ps
命令指示的 CPU 使用率对应于进程运行时的 CPU 使用率:也就是说,在它终止并成为僵尸之前。
关于python - 使用 CPU 的已失效进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22234609/