来自 shell 脚本中顶部命令的 CPU 信息



这是top命令的输出:

Mem: 245108K used, 784400K free, 6636K shrd, 15128K buff, 41824K cached
CPU:  12% usr   0% sys   0% nic  87% idle   0% io   0% irq   0% sirq
Load average: 2.62 2.58 2.57 2/90 29509

我需要单行脚本命令来执行并获取"CPU"行。

我可以从"cat/proc/

meminfo"获取Mem行,从"cat/proc/loadavg"获取负载平均值。

有没有办法为 CPU 获得相同的信息。

@md.jamal -- 试试这个,以获得具有 %CPU 和 %MEM 的前 10 个最新利用资源进程 ID。

    ps -eo pid,ppid,%cpu,%mem | sort -rnk3 | head
Below is details for above command:
where ps --> reports snapshot of current process
-e --> select all processes
-o --> output format
sort -r --> reverse sort, ie descending order
sort -n --> numeric sort
sort -k3 --> to select column no:3
head --> to display top 10 records

最新更新