Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何使用top命令显示超过某个限制的CPU使用情况?_Linux_Shell_Redhat - Fatal编程技术网

Linux 如何使用top命令显示超过某个限制的CPU使用情况?

Linux 如何使用top命令显示超过某个限制的CPU使用情况?,linux,shell,redhat,Linux,Shell,Redhat,我希望使用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

我希望使用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 ($9 > 80 ) print $1}'
完整命令应类似于:

top -bn1|awk '{ if ($9 > 80 ) print $0}'

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

如何打印每行的每一列?因为我尝试:top | awk'{如果($10>0.8)打印$13,$10}它打印出来非常奇怪output@ShiJieTio,请查看我编辑的答案。我希望跳过几行,所以我尝试(-sh-4.2$top-bn1 | awk'{if($9!=0.0)sed-n'8 12p'})但它返回语法错误,任何人都可以在这方面帮助我