在“顶部”按CPU%排序的方法?

时间:2021-02-17 21:43:34

When i run top on my Macbook (BSD?) i almost always want to sort by CPU%

当我在我的Macbook (BSD?)上运行top时,我几乎总是想按CPU%排序

it dosent seem to be the default, so I wind up typing 'o' (to sort) and type in 'cpu' and hit enter all the time!

它看起来是默认的dosent,所以我最后输入'o'(排序),输入'cpu',并一直按enter !

is there a way to make sort-by-CPU% the default or something?

有没有一种方法可以将按cpu排序的%设置为默认值?

4 个解决方案

#1


4  

%CPU is the default sort column on every system I've ever used. But if it's not, you can press Shift-P to sort by %CPU. Note that it's not listed in interactive help, only the man page.

%CPU是我使用过的每个系统的默认排序列。但如果不是,可以按Shift-P按%CPU排序。注意,它没有在交互式帮助中列出,只有man页面。

M         %MEM
N         PID
P         %CPU
T         TIME+

#2


4  

top -o +%CPU

CPU - o + %

As John Kugelman said, usually %CPU is a default sort column. Anyway, reading man top(1) seems a good idea.

正如John Kugelman所说,%CPU通常是默认的排序列。不管怎样,读《超人》似乎是个好主意。

#3


2  

Looking at the top manpage, you can use option -o %CPU, although that should already be the default. You could create an alias in your .bashrc (alias top='top -o %CPU') to make this permanent.

查看顶部的manpage,您可以使用选项-o %CPU,尽管这应该是默认设置。您可以在.bashrc(别名top='top -o %CPU')中创建一个别名,以使其永久存在。

-o  :Override-sort-field as:  -o fieldname
            Specifies  the  name of the field on which tasks will be sorted, independent of what is reflected in the configuration file.  You can prepend a '+' or '-' to the field name to
            also override the sort direction.  A leading '+' will force sorting high to low, whereas a '-' will ensure a low to high ordering.

            This option exists primarily to support automated/scripted batch mode operation.

#4


1  

Another way is to establish the sorting you prefer in top and then press W to save the configuration. Next time you start top it is going to load the config.

另一种方法是在顶部建立排序,然后按W保存配置。下次启动top时,它将加载配置。

Press h in top to see keyboard shortcuts.

在顶部按h可以看到键盘快捷键。

#1


4  

%CPU is the default sort column on every system I've ever used. But if it's not, you can press Shift-P to sort by %CPU. Note that it's not listed in interactive help, only the man page.

%CPU是我使用过的每个系统的默认排序列。但如果不是,可以按Shift-P按%CPU排序。注意,它没有在交互式帮助中列出,只有man页面。

M         %MEM
N         PID
P         %CPU
T         TIME+

#2


4  

top -o +%CPU

CPU - o + %

As John Kugelman said, usually %CPU is a default sort column. Anyway, reading man top(1) seems a good idea.

正如John Kugelman所说,%CPU通常是默认的排序列。不管怎样,读《超人》似乎是个好主意。

#3


2  

Looking at the top manpage, you can use option -o %CPU, although that should already be the default. You could create an alias in your .bashrc (alias top='top -o %CPU') to make this permanent.

查看顶部的manpage,您可以使用选项-o %CPU,尽管这应该是默认设置。您可以在.bashrc(别名top='top -o %CPU')中创建一个别名,以使其永久存在。

-o  :Override-sort-field as:  -o fieldname
            Specifies  the  name of the field on which tasks will be sorted, independent of what is reflected in the configuration file.  You can prepend a '+' or '-' to the field name to
            also override the sort direction.  A leading '+' will force sorting high to low, whereas a '-' will ensure a low to high ordering.

            This option exists primarily to support automated/scripted batch mode operation.

#4


1  

Another way is to establish the sorting you prefer in top and then press W to save the configuration. Next time you start top it is going to load the config.

另一种方法是在顶部建立排序,然后按W保存配置。下次启动top时,它将加载配置。

Press h in top to see keyboard shortcuts.

在顶部按h可以看到键盘快捷键。