top -hv | -bcHisS -d delay -n iterations -p pid [, pid ...] |
Starts top in 'Batch mode', which could be useful for sending output from top to other programs or to a file. In this mode, top will not accept input and runs until the iterations limit you've set with the '-n' command-line option or until killed.
Starts top with the last remembered 'c' state reversed. Thus, if top was displaying command lines, now that field will show program names, and visa versa. See the 'c' interactive command for additional information.
Specifies the delay between screen updates, and overrides the corresponding value in one's personal configuration file or the startup default. Later this can be changed with the 'd' or 's' interactive commands.
Fractional seconds are honored, but a negative number is not allowed. In all cases, however, such changes are prohibited if top is running in 'Secure mode', except for root (unless the 's' command-line option was used). For additional information on 'Secure mode' see topic 5a. SYSTEM Configuration File.
Show library version and the usage prompt, then quit.
Starts top with the last remembered 'H' state reversed. When this toggle is On, all individual threads will be displayed. Otherwise, top displays a summation of all threads in a process.
Starts top with the last remembered 'i' state reversed. When this toggle is Off, tasks that are idled or zombied will not be displayed.
Specifies the maximum number of iterations, or frames, top should produce before ending.
Monitor only processes with an effective UID or user name matching that given.
Monitor only processes with a UID or user name matching that given. This matches real, effective, saved, and filesystem UIDs.
Monitor only processes with specified process IDs. This option can be given up to 20 times, or you can provide a comma delimited list with up to 20 pids. Co-mingling both approaches is permitted.
This is a command-line option only. And should you wish to return to normal operation, it is not necessary to quit and and restart top — just issue the '
' interactive command.
Show library version and the usage prompt, then quit.
top - 17:02:47 up 6:31, 2 users, load average: 0.20, 0.12, 0.10 Tasks: 193 total, 1 running, 191 sleeping, 0 stopped, 1 zombie Cpu(s): 10.7%us, 9.4%sy, 0.5%ni, 75.6%id, 3.6%wa, 0.1%hi, 0.1%si, 0.0%st Mem: 1010048k total, 972080k used, 37968k free, 93464k buffers Swap: 979956k total, 127260k used, 852696k free, 292192k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3628 justin 20 0 696m 321m 25m S 5.8 32.6 40:45.77 firefox-bin 15341 justin 20 0 2464 1124 812 R 3.8 0.1 0:00.03 top 2385 root 20 0 105m 65m 6208 S 1.9 6.6 27:38.78 Xorg 1 root 20 0 2036 624 596 S 0.0 0.1 0:02.11 init
top - 17:02:47 up 6:31, 2 users, load average: 0.20, 0.12, 0.10
Tasks: 193 total, 1 running, 191 sleeping, 0 stopped, 1 zombie
Cpu(s): 10.7%us, 9.4%sy, 0.5%ni, 75.6%id, 3.6%wa, 0.1%hi, 0.1%si, 0.0%st
Cpu(s): 0.3% us 用户空间占用CPU百分比 1.0% sy 内核空间占用CPU百分比 0.0% ni 用户进程空间内改变过优先级的进程占用CPU百分比 98.7% id 空闲CPU百分比 0.0% wa 等待输入输出的CPU时间百分比 0.0% hi 0.0% si
st: stealed cpu time
hi = hardware interrupts si = software interrupts
hi — Hardware IRQ The amount of time the CPU has been servicing hardware interrupts.
si — Software Interrupts The amount of time the CPU has been servicing software interrupts.
st — Steal Time The amount of CPU 'stolen' from this virtual machine by the hypervisor for other tasks (such as running another virtual machine).
interval statics: updated by 3 seconds
Mem: 1010048k total, 972080k used, 37968k free, 93464k buffers Swap: 979956k total, 127260k used, 852696k free, 292192k cached
Mem:
191272k total 物理内存总量 173656k used 使用的物理内存总量 17616k free 空闲内存总量
22052k buffers 用作内核缓存的内存量 123988k cached 缓冲的交换区总量。
Swap:
192772k total 交换区总量 0k used 使用的交换区总量 192772k free 空闲交换区总量
内存中的内容被换出到交换区,而后又被换入到内存,但使用过的交换区尚未被覆盖, 该数值即为这些内容已存在于内存中的交换区的大小。 相应的内存再次被换出时可不必再对交换区写入。
输出和 free
相同。
Current Fields: AEHITWOQNMKbcdgfjplrsuvyzX for window 1:Def Toggle fields via field letter, type any other key to return * A: PID = Process Id 0x00000100 PF_SUPERPRIV * E: USER = User Name 0x00000200 PF_DUMPCORE * H: PR = Priority 0x00000400 PF_SIGNALED * I: NI = Nice value 0x00000800 PF_MEMALLOC * T: SHR = Shared Mem size (kb) 0x00002000 PF_FREE_PAGES (2.5) * W: S = Process Status 0x00008000 debug flag (2.5) * O: VIRT = Virtual Image (kb) 0x00024000 special threads (2.5) * Q: RES = Resident size (kb) 0x001D0000 special states (2.5) * N: %MEM = Memory usage (RES) 0x00100000 PF_USEDFPU (thru 2.4) * M: TIME+ = CPU Time, hundredths * K: %CPU = CPU usage b: PPID = Parent Process Pid c: RUSER = Real user name d: UID = User Id g: TTY = Controlling Tty f: GROUP = Group Name j: P = Last used cpu (SMP) p: SWAP = Swapped size (kb) l: TIME = CPU Time r: CODE = Code size (kb) s: DATA = Data+Stack size (kb) u: nFLT = Page Fault count v: nDRT = Dirty Pages count y: WCHAN = Sleeping in Function z: Flags = Task Flags <sched.h> * X: COMMAND = Command name/line Flags field: 0x00000001 PF_ALIGNWARN 0x00000002 PF_STARTING 0x00000004 PF_EXITING 0x00000040 PF_FORKNOEXEC
a: PID — Process Id The task's unique process ID, which periodically wraps, though never restarting at zero.
b: PPID — Parent Process Pid The process ID of a task's parent.
c: RUSER — Real User Name The real user name of the task's owner.
d: UID — User Id The effective user ID of the task's owner.
e: USER — User Name The effective user name of the task's owner.
f: GROUP — Group Name The effective group name of the task's owner.
g: TTY — Controlling Tty The name of the controlling terminal. This is usually the device (serial port, pty, etc.) from which the process was started, and which it uses for input or output. However, a task need not be associated with a terminal, in which case you'll see '?' displayed.
h: PR — Priority The priority of the task.
i: NI — Nice value The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. Zero in this field simply means priority will not be adjusted in determining a task's dispatchability.
j: P — Last used CPU (SMP) A number representing the last used processor. In a true SMP environment this will likely change frequently since the kernel intentionally uses weak affinity. Also, the very act of running top may break this weak affinity and cause more processes to change CPUs more often (because of the extra demand for cpu time).
k: %CPU — CPU usage The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's cpu usage will be divided by the total number of CPUs. You toggle 'Irix/Solaris' modes with the 'I' interactive command.
l: TIME — CPU Time Total CPU time the task has used since it started. When 'Cumulative mode' is On, each process is listed with the cpu time that it and its dead children has used. You toggle 'Cumulative mode' with 'S', which is a command-line option and an interactive command. See the 'S' interactive command for additional information regarding this mode.
m: TIME+ — CPU Time, hundredths The same as 'TIME', but reflecting more granularity through hundredths of a second.
TIME = TIME+
n: %MEM — Memory usage (RES) A task's currently used share of available
physical memory
.
VIRT = SWAP + RES
o: VIRT — Virtual Image (kb) The total amount of
virtual memory
used by the task. It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.
p: SWAP — Swapped size (kb) Memory that is not resident but is present in a task. This is memory that has been swapped out but could include additional non-resident memory. This column is calculated by subtracting physical memory from virtual memory.
q: RES — Resident size (kb) The non-swapped
physical memory
a task has used.
r: CODE — Code size (kb) The amount of
virtual memory
devoted to executable code, also known as the 'text resident set' size or TRS.
s: DATA — Data+Stack size (kb) The amount of
virtual memory
devoted to other than executable code, also known as the 'data resident set' size or DRS.
t: SHR — Shared Mem size (kb) The amount of shared memory used by a task. It simply reflects memory that could be potentially shared with other processes.
u: nFLT — Page Fault count The number of major page faults that have occurred for a task. A page fault occurs when a process attempts to read from or write to a virtual page that is not currently present in its address space. A major page fault is when backing storage access (such as a disk) is involved in making that page available.
v: nDRT — Dirty Pages count The number of pages that have been modified since they were last written to disk. Dirty pages must be written to disk before the corresponding physical memory location can be used for some other virtual page.
w: S — Process Status The status of the task which can be one of: 'D' = uninterruptible sleep 'R' = running 'S' = sleeping 'T' = traced or stopped 'Z' = zombie
Tasks shown as running should be more properly thought of as 'ready to run' — their task_struct is simply represented on the Linux run-queue. Even without a true SMP machine, you may see numerous tasks in this state depending on top's delay interval and nice value.
x: Command — Command line or Program name Display the command line used to start a task or the name of the associated program. You toggle between command line and name with 'c', which is both a command-line option and an interactive command.
When you've chosen to display command lines, processes without a command line (like kernel threads) will be shown with only the program name in parentheses, as in this example: ( mdrecoveryd )
Either form of display is subject to potential truncation if it's too long to fit in this field's current width. That width depends upon other fields selected, their order and the current screen width.
Note: The 'Command' field/column is unique, in that it is not fixed-width. When displayed, this column will be allocated all remaining screen width (up to the maximum 512 characters) to provide for the potential growth of program names into command lines.
y: WCHAN — Sleeping in Function Depending on the availability of the kernel link map ('System.map'), this field will show the name or the address of the kernel function in which the task is currently sleeping. Running tasks will display a dash ('-') in this column.
Note: By displaying this field, top's own working set will be increased by over 700Kb. Your only means of reducing that overhead will be to stop and restart top.
z: Flags — Task Flags This column represents the task's current scheduling flags which are expressed in hexadecimal notation and with zeros suppressed. These flags are officially documented in <linux/sched.h>. Less formal documentation can also be found on the 'Fields select' and 'Order fields' screens.
Help for Interactive Commands - procps version 3.2.8 Window 1:Def: Cumulative mode Off. System: Delay 3.0 secs; Secure mode Off. Z,B Global: 'Z' change color mappings; 'B' disable/enable bold l,t,m Toggle Summaries: 'l' load avg; 't' task/cpu stats; 'm' mem info 1,I Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode f,o . Fields/Columns: 'f' add or remove; 'o' change display order F or O . Select sort field <,> . Move sort field: '<' next col left; '>' next col right R,H . Toggle: 'R' normal/reverse sort; 'H' show threads c,i,S . Toggle: 'c' cmd name/line; 'i' idle tasks; 'S' cumulative time x,y . Toggle highlights: 'x' sort field; 'y' running tasks z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y') u . Show specific user only n or # . Set maximum tasks displayed k,r Manipulate tasks: 'k' kill; 'r' renice d or s Set update interval W Write configuration file q Quit ( commands shown with '.' require a visible task display window ) Press 'h' or '?' for help with Windows, any other key to continue
Help for Windows / Field Groups - "Current Window" = 1:Def . Use multiple windows, each with separate config opts (color,fields,sort,etc) . The 'current' window controls the Summary Area and responds to your Commands . that window's task display can be turned Off & On, growing/shrinking others . with NO task display, some commands will be disabled ('i','R','n','c', etc) until a different window has been activated, making it the 'current' window . You change the 'current' window by: 1) cycling forward/backward; 2) choosing a specific field group; or 3) exiting the color mapping screen . Commands available anytime ------------- A . Alternate display mode toggle, show Single / Multiple windows G . Choose another field group and make it 'current', or change now by selecting a number from: 1 =Def; 2 =Job; 3 =Mem; or 4 =Usr . Commands requiring 'A' mode ------------- g . Change the Name of the 'current' window/field group * a , w . Cycle through all four windows: 'a' Forward; 'w' Backward * - , _ . Show/Hide: '-' Current window; '_' all Visible/Invisible The screen will be divided evenly between task displays. But you can make some larger or smaller, using 'n' and 'i' commands. Then later you could: * = , + . Rebalance tasks: '=' Current window; '+' Every window (this also forces the current or every window to become visible) In 'A' mode, '*' keys are your essential commands. Please try the 'a' and 'w' commands plus the 'G' sub-commands NOW. Press <Enter> to make 'Current'Wiki comments powered by Disqus