首页
首页 » 系统管理 » ps(process status)

ps(process status)

ps(process status)
功能说明:报告程序状况。
语  法:ps [-aAcdefHjlmNVwy][acefghLnrsSTuvxX][-C <指令名称>][-g <群组名称>][-G <群组识别码>][-p <程序识别码>][p <程序识别码>][-s <阶段作业>][-t <终端机编号>][t <终端机编号>][-u <用户识别码>][-U <用户识别码>][U <用户名称>][-<程序识别码>][--cols <每列字符数>][--columns <每列字符数>][--cumulative][--deselect][--forest][--headers][--help][--info][--lines <显示列数>][--no-headers][--group <群组名称>][-Group <群组识别码>][--pid <程序识别码>][--rows <显示列数>][--sid <阶段作业>][--tty <终端机编号>][--user <用户名称>][--User <用户识别码>][--version][--width <每列字符数>]
补充说明:ps是用来报告程序执行状况的指令,您可以搭配kill指令随时中断,删除不必要的程序。
参  数:
 -a  显示所有终端机下执行的程序,除了阶段作业领导者之外。 
 a  显示现行终端机下的所有程序,包括其他用户的程序。 
 -A  显示所有程序。 
 -c  显示CLS和PRI栏位。 
 c  列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。 
 -C<指令名称>  指定执行指令的名称,并列出该指令的程序的状况。 
 -d  显示所有程序,但不包括阶段作业领导者的程序。 
 -e  此参数的效果和指定"A"参数相同。 
 e  列出程序时,显示每个程序所使用的环境变量。 
 -f  显示UID,PPIP,C与STIME栏位。 
 f  用ASCII字符显示树状结构,表达程序间的相互关系。 
 -g<群组名称>  此参数的效果和指定"-G"参数相同,当亦能使用阶段作业领导者的名称来指定。 
 g  显示现行终端机下的所有程序,包括群组领导者的程序。 
 -G<群组识别码>  列出属于该群组的程序的状况,也可使用群组名称来指定。 
 h  不显示标题列。 
 -H  显示树状结构,表示程序间的相互关系。 
 -j或j  采用工作控制的格式显示程序状况。 
 -l或l  采用详细的格式来显示程序状况。 
 L  列出栏位的相关信息。 
 -m或m  显示所有的执行绪。 
 n  以数字来表示USER和WCHAN栏位。 
 -N  显示所有的程序,除了执行ps指令终端机下的程序之外。 
 -p<程序识别码>  指定程序识别码,并列出该程序的状况。 
 p<程序识别码>  此参数的效果和指定"-p"参数相同,只在列表格式方面稍有差异。 
 r  只列出现行终端机正在执行中的程序。 
 -s<阶段作业>  指定阶段作业的程序识别码,并列出隶属该阶段作业的程序的状况。 
 s  采用程序信号的格式显示程序状况。 
 S  列出程序时,包括已中断的子程序资料。 
 -t<终端机编号>  指定终端机编号,并列出属于该终端机的程序的状况。 
 t<终端机编号>  此参数的效果和指定"-t"参数相同,只在列表格式方面稍有差异。 
 -T  显示现行终端机下的所有程序。 
 -u<用户识别码>  此参数的效果和指定"-U"参数相同。 
 u  以用户为主的格式来显示程序状况。 
 -U<用户识别码>  列出属于该用户的程序的状况,也可使用用户名称来指定。 
 U<用户名称>  列出属于该用户的程序的状况。 
 v  采用虚拟内存的格式显示程序状况。 
 -V或V  显示版本信息。 
 -w或w  采用宽阔的格式来显示程序状况。  
 x  显示所有程序,不以终端机来区分。 
 X  采用旧式的Linux i386登陆格式显示程序状况。 
 -y  配合参数"-l"使用时,不显示F(flag)栏位,并以RSS栏位取代ADDR栏位 。 
 -<程序识别码>  此参数的效果和指定"p"参数相同。 
 --cols<每列字符数>  设置每列的最大字符数。 
 --columns<每列字符数>  此参数的效果和指定"--cols"参数相同。 
 --cumulative  此参数的效果和指定"S"参数相同。 
 --deselect  此参数的效果和指定"-N"参数相同。 
 --forest  此参数的效果和指定"f"参数相同。 
 --headers  重复显示标题列。 
 --help  在线帮助。 
 --info  显示排错信息。 
 --lines<显示列数>  设置显示画面的列数。 
 --no-headers  此参数的效果和指定"h"参数相同,只在列表格式方面稍有差异。 
 --group<群组名称>  此参数的效果和指定"-G"参数相同。 
 --Group<群组识别码>  此参数的效果和指定"-G"参数相同。 
 --pid<程序识别码>  此参数的效果和指定"-p"参数相同。 
 --rows<显示列数>  此参数的效果和指定"--lines"参数相同。 
 --sid<阶段作业>  此参数的效果和指定"-s"参数相同。 
 --tty<终端机编号>  此参数的效果和指定"-t"参数相同。 
 --user<用户名称>  此参数的效果和指定"-U"参数相同。 
 --User<用户识别码>  此参数的效果和指定"-U"参数相同。 
 --version  此参数的效果和指定"-V"参数相同。 
 --widty<每列字符数>  此参数的效果和指定"-cols"参数相同。

ps

ps [options]

Report on active processes. ps has three types of options. GNU long options start with two hyphens, which are required. BSD options may be grouped and do not start with a hyphen, while Unix98 options may be grouped and require an initial hyphen. The meaning of the short options can vary depending on whether or not there is a hyphen. In options, list arguments should either be comma-separated or space-separated and placed inside double quotes. In comparing the amount of output produced, note that e prints more than a and l prints more than f for each entry.

Options

nums, p nums, -p nums, --pid=nums

Include only specified processes, which are given in a space-delimited list.

-nums, -s nums, --sid=nums

Include only specified session IDs, which are given in a space-delimited list.

[-] a

As a, list all processes on a terminal. As -a, list all processes except session leaders and processes not associated with a terminal.

[-] c

As -c, show different scheduler information with -l. As c, show the true command name.

-C cmds

Select by command name.

--cols=cols, --columns=cols

Set the output width (the number of columns to display).

-d

Select all processes except session leaders.

-e, -A

Select all processes.

e

Include environment information after the command.

[-] f, --forest

As -f, display full listing. As f or --forest, display "forest" family tree format, with ASCII art showing the relationships.

-F

Set extra-full format; implies -f.

-g list, -G list, --group=groups, --Group=groups

For -g, select by session leader if list contains numbers, or by group if it contains group names. For -G, select by the group IDs in list. --group selects by effective group and --Group selects by real group, where groups can be either group names or group IDs.

h, --no-headers

Suppress header. If you select a BSD personality by setting the environment variable PS_PERSONALITY to bsd, then h prints a header on each page.

-H

Display "forest" family tree format, but without ASCII art.

H

Display threads as if they were processes.

--headers

Repeat headers on every output page.

--help

Display help information and exit.

--info

Print debugging information.

[-] j

Jobs format. j prints more information than -j.

-k spec, --sort spec

Specify sort order. Syntax for the specification is:

[+|-] key[,[+|-] key...] ]

The default direction is +, for increasing numerical or alphabetic order. See Format and sort specifiers for possible keys.

[-] l

Produce a long listing. -l prints more information than l and is often used with -y.

L

Print list of field specifiers that can be used for output formatting or for sorting.

-L

Show threads, possibly with LWP and NLWP columns.

--lines=num, --rows=num

Set the screen height to num lines. If --headers is also set, the headers repeat every num lines.

[-] m

Show threads after processes.

n

Print user IDs and WCHAN numerically.

-n file, N file

Specify the System.map file for ps to use as a namelist file. The map file must correspond to the Linux kernel—e.g., /boot/System.map-2.4.19.

-N, --deselect

Negate the selection, selecting all processes that do not meet the specified conditions.

[-] o fields, --format=fields

As -o, o, or --format, specify user-defined format with a list of fields to display.

[-] O fields

As -O, this option is like -o, but some common fields are predefined. As O, this option can be either the same as -O in specifying fields to display, or can specify single-letter fields for sorting. For sorting, each field specified as a key can optionally have a leading + (return to default sort direction on key) or - (reverse the default direction).

--ppid=nums

Select by parent process IDs.

r

Show only processes that are currently running.

s

Display signal format.

-S, --cumulative

Include some dead child process data in parent total.

[-] tttys, --tty=ttys

Display processes running on the specified terminals. t with no terminal list displays processes for the terminal associated with ps. Specify - to select processes not associated with any terminal.

T

Display all processes on this terminal. Like t with no argument.

-T

Display threads, possibly with SPID column,

[-] u [users] , --user=users

As u with no argument, display user-oriented output. As -u or --user, display by effective user ID (and also support names), showing results for users. With no argument, -u displays results for the current user.

[-] U users, --User=users

As U, display processes by effective user ID. As -U or --User, display processes for users by real user ID (and also support names).

v

Display virtual memory format.

[-] V, --version

Display version information and then exit.

[-] w

Wide format. Don't truncate long lines. Use twice to set an unlimited width.

--width=cols

Set screen width.

x

Display processes without an associated terminal.

X

Use old Linux i386 register format.

-y

Do not show flags; show rss instead of addr. Requires -l.

Format and sort specifiers

The following are the keywords for formatting and for sorting with --sort, followed by a desciption and the output column header in parentheses:

%cpu, pcpu

Percent of CPU time used recently. (%CPU)

%mem, pmem

Percent of memory used. (%MEM)

args, cmd, command

The command the process is running with all its arguments. (CMD for cmd; otherwise COMMAND)

blocked, sig_block, sigmask

Mask, in hexadecimal, of blocked signals. (BLOCKED)

bsdstart

Command start time. (START)

bsdtime

Accumulated CPU time for user plus system. (TIME)

c

Integer value of %cpu. (C)

caught, sig_catch, sigcatch

Mask, in hexadecimal, of caught signals. (CAUGHT)

class, cls, policy

Scheduling class. (POL for policy, otherwise CLS). Possible values are:

-

Unreported

?

Unknown value

FF

SCHED_FIFO (first in, first out)

RR

SCHED_RR (round robin)

TS

SCHED_OTHER (standard time-sharing)

comm, ucmd, ucomm

Name of the command executable. (CMD for ucmd, otherwise COMMAND)

cp

Per-mill CPU usage, where mill is 1000. Equivalent to %cpu with no decimal point. (CP)

cputime, time

Cumulative CPU time. (TIME)

egid, gid

Effective group ID number in decimal. (EGID or GID, respectively)

egroup, group

Effective group ID; as text value if it is available and if it fits, otherwise shown as decimal value. (EGROUP or GROUP, respectively)

eip

Effective instruction pointer. (EIP)

esp

Effective stack pointer. (ESP)

etime

Elapsed time since the start of the process. (ELAPSED)

euid, uid

Effective user ID. (EUID or UID, respectively)

euser, uname, user

Effective username; as text value if it is available and if it fits, otherwise shown as decimal value (EUSER for euser; otherwise USER).

f, flag, flags

Process flags. Can be summed. (F) Possible values are:

1

Forked but didn't exec.

4

Used superuser privileges.

fgid, fsgid

Filesystem access group ID. (FGID)

fgroup, fsgroup

Filesystem access group ID; as text if available and if it fits, otherwise as a decimal number. (FGROUP)

fname

First eight bytes of the executable's basename. (COMMAND)

fuid, fsuid

Filesystem access user ID. (FUID)

fuser

Filesystem access user ID; as text if available and if it fits, otherwise as a decimal number. (FUSER)

ignored, sig_ignore, sigignore

Mask of ignored signals in hexadecimal format. (IGNORED)

lstart

Command start time. (LSTART)

lwp, spid, tid

Light-weight process, or thread, ID. (LWP, SPID, TID, respectively)

ni, nice

The nice value of the process. A higher number indicates less CPU time. (NI)

nlwp, thcount

Number of LWPs, or threads, in the process. (NLWP or THCNT, respectively)

nwchan

Address of kernel function where process is sleeping. See also wchan to get the function by name. (WCHAN)

pending, sig, sig_pend

Mask of pending signals. Use with the m or -m option to see both signals pending on the process and on individual threads. (PENDING)

pgid, pgrp

Process group ID or ID of process group leader, which are equivalent. (PGID or PGRP, respectively)

pid

Process ID. (PID)

ppid

Parent process ID. (PPID)

pri

Process's scheduling priority. A higher number indicates lower priority. (PRI)

psr

Current processor that the process is running on. (PSR)

rgid

Real group ID. (RGID)

rgroup

Real group name; as text if available and it fits, otherwise as a decimal number. (RGROUP)

rss, rssize, rsz

Resident set size (the amount of physical memory), in kilobytes. (RSZ for rsz; otherwise RSS)

rtprio

Real-time priority. (RTPRIO)

ruid

Real user ID number. (RUID)

ruser

Real user ID; as text if available and it fits, otherwise as a decimal number. (RUSER)

s, state

A single-character state display. See stat for the possible characters or for a multicharacter display. (S)

sched

Scheduling policy. Also see class. (SCH) Possible values are:

0

SCHED_OTHER

1

SCHED_FIFO

2

SCHED_RR

sess, session, sid

Session ID, or the process ID of the session leader, which is equivalent. (SID for sid; otherwise SESS)

sgi_p

Processor on which the process is currentlly running, or "*" if the process is not running. (P)

sgid, svgid

Saved group ID. (SGID or SVGID, respectively)

sgroup

Saved group name; as text if available and it fits, otherwise as a decimal number.

size

Size of virtual image. Provides a rough estimate of the swapspace required to swap the process out. Note that sz uses the same column header, but has a different meaning. (SZ)

stackp

Address of the stack bottom (start of the stack). (STACKP)

start

Start time of the command. (STARTED)

start_time

Starting time or date of the process. (START)

stat

Status. Multiple status characters can appear. See also s to display a single character. (STAT)

+

Part of foreground process group.

<

High priority (not "nice").

D

Asleep and not interruptible.

l

Multi-threaded.

L

Pages locked into memory.

N

Low priority ("nice").

R

Runnable.

s

Session leader.

S

Asleep.

T

Stopped.

W

No resident pages (second field).

Z

Zombie.

suid, svuid

Saved user ID. (SUID or SVUID respectively)

suser, svuser

Saved username; as text if it is available and it fits, otherwise as a decimal number. (SUSER or SVUSER respectively)

sz

Physical page size of the core image of the process, including text, data and stack space. (SZ)

tpgid

ID of the foreground process group on the associated terminal for the process, or -1 if not connected to a terminal. (TPGID)

tt, tty, tname

Associated (controlling) terminal. (TTY for tname; otherwise TT)

uid

User ID. (UID)

vsz, vsize

Virtual memory size, in kilobytes of the entire process. (VSZ)

wchan

Kernel function in which process is sleeping, or "-" if running, or "*" if multithreaded process and ps is not displaying threads. (WCHAN)