我知道,一旦运行,top
如果按下,1您可以看到每个处理器上的负载(让我们忘记多线程问题),如果按下,s您可以配置刷新时间。
如何将此选项放入启动命令中?
我正在尝试记录输出
$ top -b -p $(pidof myprocess) > top.log
但我希望看到我的四个处理器和更高的刷新率。
答案1
Linuxtop
支持配置文件 ( ~/.toprc
),它也可以从运行配置中写入:
- 开始
top
- 启用您想要的选项(颜色、更新频率、排序顺序、显示的统计信息……)
- 点击
W
(即,shift+w)
下次运行时top
,它将读取您的配置并将其默认值更改为您要求的内容。
答案2
图中显示top manpage
了Startup Defaults
可从 进行配置的commandline
。显示器Cpu
不是其中之一。
Startup Defaults
The following startup defaults assume no configuration file, thus no user customizations. Even so, items shown with an asterisk (’*’) could be overridden through the command-
line.
Global_defaults
’A’ - Alt display Off (full-screen)
* ’d’ - Delay time 3.0 seconds
’I’ - Irix mode On (no, ’solaris’ smp)
* ’p’ - PID monitoring Off
* ’s’ - Secure mode Off (unsecured)
’B’ - Bold disable Off
Summary_Area_defaults
’l’ - Load Avg/Uptime On (thus program name)
’t’ - Task/Cpu states On (1+1 lines, see ’1’)
’m’ - Mem/Swap usage On (2 lines worth)
’1’ - Single Cpu On (thus 1 line if smp)
Task_Area_defaults
’b’ - Bold hilite On (not ’reverse’)
* ’c’ - Command line Off (name, not cmdline)
* ’H’ - Threads Off (show all threads)
* ’i’ - Idle tasks On (show all tasks)
’R’ - Reverse sort On (pids high-to-low)
* ’S’ - Cumulative time Off (no, dead children)
’x’ - Column hilite Off (no, sort field)
’y’ - Row hilite On (yes, running tasks)
’z’ - color/mono Off (no, colors)
这可以使用top
配置文件来完成。来自top manpage
:
5b. PERSONAL Configuration File
This file is written as ’$HOME/.your-name-4-top’ + ’rc’. Use the ’W’ interactive command to create it or update it.
top
创建开始显示所有处理器的配置文件的步骤:
1. Start `top`.
2. Toggle display of all CPUs (press 1).
3. Press `d` or `s` and set new delay (default=3.0 seconds). (This can be set on the `commandline`. See the `Startup Defaults` above.
4. Press Shift+W. Notice message 'Wrote configuration to '/home/youruser/.toprc'.
5. Quit `top`.
6. Start `top`. Until you rewrite the `top` configuration file with a different option (Step #3), it will start with all CPUs showing.