示例:
系统内存状况:
total used free shared buffers cached
Mem: 12147396 11982020 165376 0 39408 4487020
ps -aux 拿出来一个例子:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 17099 143 1.0 3659280 129980 ? Sl Feb26 14654:43 ./a.out -100
解释:
VSZ: 程序占用的总虚拟内存大小(3659280 KB)
virtual memory size of the process in KiB (1024-byte units). Device mappings are currently excluded; this is subject to change. (alias vsize).
RSS: 程序占用的常住内存,也就是不可以被替换到交换区的内存大小(129980 KB)
resident set size, the non-swapped physical memory that a task has used (in kiloBytes). (alias rssize, rsz).
STAT: 程序的状态,详解见最后:PROCESS STATE CODES( Sl, 正在睡眠,可以中断,多线程)
multi-character process state. See section PROCESS STATE CODES for the different values meaning.See also s and state if you just want the first character displayed.
TTY: 程序所属的终端,如果是?, 代表是后台程序
controlling tty (terminal). (alias tname, tt).
START: 程序开始时间(2月26号)
time the command started. If the process was started less than 24 hours ago, the output format is"HH:MM:SS", else
it is " <mm dd" (where Mmm is a three-letter month name).
%MEM: 程序占用的常住内存大小在系统总内存中的比例,ie: RSS / total(129980/12147396)
ratio of the process's resident set size to the physical memory on the machine, expressed as apercentage. (alias
pmem).
%CPU: 程序占用各个CPU时间之和除以程序运行总时间,所以如果是多核系统,这个值可能大于100, 本例143
cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time theprocess has been running (cputime/realtime ratio), expressed as a percentage. It will not add up to
100%unless you are lucky. (alias pcpu). It can be larger than 100% when your machine is multi-CPU.
PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent.
For BSD formats and when the stat keyword is used, additional characters may be displayed:
< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group.
ps: 看了好多文章,还是man ps的结果最给力!!!!!