如何使用top命令显示CPU使用量超过一定限度?

How to use the top command to display CPU usage above a certain limit?

我希望使用 shell 脚本过滤 linux 中 CPU 使用率高(超过 80%)的进程

顶部

PID      USER       PR    NI     VIRT    RES    SHR   S    CPU   MEM   TIME+COMMAND
1        Alan       20    0      4999    444    45    S    1.7   0.8     10:10.00 helloworld
2        Alan       20    0      49993   4443  435    S    8.7   0.8     10:10.00 helloworld

任何人都可以分享有关显示这些进程的 PID 的想法吗?

您可以像这样使用 awk 脚本

awk '{ if ( > 80 ) print }'

完整的命令应该是这样的:

top -bn1|awk '{ if ( > 80 ) print [=11=]}'

这将只执行一次top并打印整行