Linux 使用过多 CPU 查找进程的命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15103662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Command for finding process using too much CPU
提问by user1136342
What command can I use to find a process that's using a lot of CPU? Can I do this without installing something new?
我可以使用什么命令来查找使用大量 CPU 的进程?我可以在不安装新东西的情况下做到这一点吗?
回答by Gilles Quenot
Try doing this :
尝试这样做:
top -b -n1 -c
And if you want the process that takes the most %CPU times :
如果您想要占用最多 %CPU 时间的进程:
top -b -n1 -c | awk '/PID *USER/{print;getline;print}'
or
或者
top -b -n1 -c | grep -A 2 '^$'
回答by squiguy
Or using a few other utils you could do:
或者使用其他一些实用程序,您可以这样做:
ps aux | sort -rk 3,3 | head -n 5
Change the value of head to get the number of processes you want to see.
更改 head 的值以获取您想要查看的进程数。