Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
您的位置: Linux安全网 > Linux培训 > » 正文


来源: 未知 分享至:


top 命令的参数中没有方法可以直接做到。

man top 写道 NAME
top - display Linux tasks

top -hv | -bcHisS -d delay -n iterations -p pid [, pid ...]

The traditional switches ’-’ and whitespace are optional.

-b : Batch mode operation
-c : Command line/Program name toggle
-d : Delay time interval as: -d (seconds.tenths)
-h : Help
-H : Threads toggle
-i : Idle Processes toggle
-n : Number of iterations limit as: -n number
-u : Monitor by user as: -u somebody
-U : Monitor by user as: -U somebody
-p : Monitor PIDs as: -pN1 -pN2 ... or -pN1, N2 [,...]
-s : Secure mode operation
-S : Cumulative time mode toggle
-v : Version
-M : Detect memory units

但是可以在文本全屏界面显示出来之后使用交互式命令来进行,比如 按大写M可以使进程显示按内存使用排序,按大写P按CPU使用排序。

按大写W可以将当前的设置保存到配置文件中,一般就是 ~/.toprc,这样就可以在下次启动top命令是按照设定的排序方式来显示了。

man top 写道 W :Write_the_Configuration_File
This will save all of your options and toggles plus the current
display mode and delay time. By issuing this command just
before quitting top, you will be able restart later in exactly
that same state.

1 :Toggle_Single/Separate_Cpu_States -- On/Off
This command affects how the ’t’ command’s Cpu States portion is
shown. Although this toggle exists primarily to serve mas-
sively-parallel SMP machines, it is not restricted to solely SMP

SORTING of task window
For compatibility, this top supports most of the former top sort
keys. Since this is primarily a service to former top users, these
commands do not appear on any help screen.
command sorted field supported
A start time (non-display) No
M %MEM Yes
P %CPU Yes

下面是一个 ~/.toprc 文件的样本。这个文件有点复杂,没仔细看过。

RCfile for "top with windows"           # shameless braggin'
Id:a, Mode_altscr=0, Mode_irixps=1, Delay_time=3.000, Curwin=0
Def     fieldscur=AEHIOQTWKNMbcdfgjplrsuvyzX
        winflags=62777, sortindx=13, maxtasks=0
        summclr=1, msgsclr=1, headclr=3, taskclr=1
Job     fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
        winflags=62777, sortindx=0, maxtasks=0
        summclr=6, msgsclr=6, headclr=7, taskclr=6
Mem     fieldscur=ANOPQRSTUVbcdefgjlmyzWHIKX
        winflags=62777, sortindx=13, maxtasks=0
        summclr=5, msgsclr=5, headclr=4, taskclr=5
Usr     fieldscur=ABDECGfhijlopqrstuvyzMKNWX
        winflags=62777, sortindx=4, maxtasks=0
        summclr=3, msgsclr=3, headclr=2, taskclr=3

1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史