本文来自:https://www.ibm.com/docs/en/aix/7.1?topic=p-ps-command
ps [ -A ] [ -M ] [ -N ] [ -Z ] [ -a ] [ -d ] [ -e ] [ -f ] [ -k ] [ -l ] [ -F format] [ -o Format ] [ -c Clist ] [ -G Glist ] [ -g Glist ] [ -m ] [ -n NameList ] [ -p Plist ] [ -P ] [ -t Tlist ] [ -U Ulist ] [ -u Ulist ] [ -T pid ] [ -L pidlist ] [ -X ] [ -@ [ WparName ] ]
Berkeley Standards
ps [ a ] [ c ] [ e ] [ ew ] [ eww ] [ ewww ] [ g ] [ n ] [ w ] [ x ] [ l | s | u | v ] [ t tty ] [ X ] [ ProcessNumber ]
The ps command writes the status of active processes and if the -m flag is given, displays the associated kernel threads to standard output. While the -m flag displays threads associated with processes using extra lines, you must use the -o flag with the THREAD field specifier to display extra thread-related columns.
Without flags, the ps command displays information about the current terminal. The -f, -o, l, -l, s, u, and v flags only determine how much information is provided about a process; they do not determine which processes are listed. The l, s, u, and v flags are mutually exclusive.
With the -o flag, the ps command examines memory or the paging area and determines what the command name and parameters were when the process was created. If the ps command cannot find this information, the command name stored in the kernel is displayed in square brackets.
The COLUMNS environment variable overrides the system-selected, horizontal screen size.
The command-line flags that accept a list of parameters (the -o, -G, -g, -p, -t, -U, and -u flags) are limited to 128 items. For example, the -u Ulist flag can specify no more than 128 users.
For cases in which the output of the ps command does not include workload partition ( WPAR) names but does include Project IDs ( PROJECT), User IDs ( UID or USER), or Group IDs ( GID) associated with a process running within a workload partition under the current operating environment, the IDs are preceded by a plus sign (+) to indicate the association with a workload partition. Each workload partition contains its own definition of users, groups, and project IDs that may be different from the IDs defined for the global environment. The -@ option may be specified to include workload partition names in the output.
Depending on the flags used with the ps command, column headings are displayed above the information displayed to standard output. The headings are defined in the following list and the flags that cause these headings to be displayed are shown in parentheses :
|
Flags |
Hexadecimal Value |
Definition |
|---|---|---|
| SLOAD | 0x00000001 | Indicates that the process is operating in core memory. |
| SNOSWAP | 0x00000002 | Indicates that the process cannot be swapped out. |
| STRC | 0x00000008 | Indicates that the process is being traced. |
| SWTED | 0x00000010 | Indicates that the process stopped while being traced. |
| SFWTED | 0x00000020 | Indicates that the process stopped after a call to the forksubroutine, while being traced. |
| SEWTED | 0x00000040 | Indicates that the process stopped after a call to the execsubroutine, while being traced. |
| SLWTED | 0x00000080 | Indicates that the process stopped after a call to the load or unload subroutine, while being traced. |
| SFIXPRI | 0x00000100 | Indicates that the process has a fixed priority, ignoring the pcpu field descriptor. |
| SKPROC | 0x00000200 | Indicates a Kernel process. |
| SOMASK | 0x00000400 | Indicates restoration of the old mask after a signal is received. |
| SWAKEONSIG | 0x00000800 | Indicates that the signal will abort the sleep subroutine. The contents must not be equal to those of the PCATCH flag. The contents of both PCATCH and SWAKEONSIG must be greater than those of PMASK. |
| SUSER | 0x00001000 | Indicates that the process is in user mode. |
| SLKDONE | 0x00002000 | Indicates that the process has done locks. |
| STRACING | 0x00004000 | Indicates that the process is a debugging process. |
| SMPTRACE | 0x00008000 | Indicates multi-process debugging. |
| SEXIT | 0x00010000 | Indicates that the process is exiting. |
| SSEL | 0x00020000 | Indicates that the processor is selecting: wakeup/waiting danger. |
| SORPHANPGRP | 0x00040000 | Indicates an orphaned process group. |
| SNOCNTLPROC | 0x00080000 | Indicates that the session leader relinquished the controlling terminal. |
| SPPNOCLDSTOP | 0x00100000 | Indicates that the SIGHLD signal is not sent to the parent process when a child stops. |
| SEXECED | 0x00200000 | Indicates that process has been run. |
| SJOBSESS | 0x00400000 | Indicates that job control was used in the current session. |
| SJOBOFF | 0x00800000 | Indicates that the process is free from job control. |
| PSIGDELIVERY | 0x01000000 | Indicates that the process is used by the program-check handler. |
| SRMSHM | 0x02000000 | Indicates that the process removed shared memory during a call to the exit subroutine. |
| SSLOTFREE | 0x04000000 | Indicates that the process slot is free. |
| SNOMSG | 0x08000000 | Indicates that there are no more uprintf subroutine messages. |
|
Flags |
Hexadecimal Value |
Definition |
|---|---|---|
| SLOAD | 0x00000001 | Indicates that the process is operating in core memory. |
| SNOSWAP | 0x00000002 | Indicates that the process cannot be swapped out. |
| STRC | 0x00000008 | Indicates that the process is being traced. |
| SKPROC | 0x00000200 | Indicates a kernel process. |
| SEXIT | 0x00010000 | Indicates that the process is exiting. |
| SLPDATA | 0x00020000 | Indicates that the process uses large pages. |
| SEXECED | 0x00200000 | Indicates that the process has been run. |
| SEXECING | 0x01000000 | Indicates that the process is execing (performing an exec). |
| SPSEARLYALLOC | 0x04000000 | Indicates that paging space for this process is allocated early. |
| TKTHREAD | 0x00001000 | Indicates that the thread is a kernel-only thread. |
For processes:
For kernel threads:
The following flags are preceded by a - (minus sign):
|
Item |
Description |
|---|---|
| -A | Writes to standard output information about all processes. |
| -a | Writes to standard output information about all processes, except the session leaders and processes not associated with a terminal. |
| -c Clist | Displays only information about processes assigned to the workload management classes listed in the Clistvariable. The Clist variable is either a comma-separated list of class names or a list of class names enclosed in double quotation marks (" "), which is separated from one another by a comma or by one or more spaces, or both. |
| -d | Writes information to standard output about all processes, except the session leaders. |
| -e | Writes information to standard output about all processes, except kernel processes. |
| -F Format | Same as the -o Format |
| -f | Generates a full listing. |
| -G Glist | Writes information to standard output only about processes that are in the effective groups listed for the Glist variable. The Glist variable is either a comma-separated list of effective group identifiers, or a list of effective group identifiers enclosed in double quotation marks (" ") and separated from one another by a comma or by one or more spaces. |
| -g Glist | Writes information to standard output only about processes that are in the process groups listed for the Glist variable. The Glist variable is either a comma-separated list of process group identifiers or a list of process group identifiers enclosed in double quotation marks (" ") and separated from one another by a comma or by one or more spaces. |
| -k | Lists kernel processes. |
| -l | Generates a long listing. Also see the l flag. |
| -L pidlist | Generates a list of descendants of each and every pid that has been passed to it in the pidlist variable. The pidlist variable is a list of comma-separated process IDs. The list of descendants from all the given pid is printed in the order in which they appear in the process table. |
| -M | Lists all 64 bit processes. |
| -m | Lists kernel threads as well as processes. Output lines for processes are followed by an additional output line for each kernel thread. This flag does not display thread-specific fields ( bnd, scount, sched, thcount, and tid), unless the appropriate -o Format flag is specified. |
| -N | Gathers no thread statistics. With this flag, ps reports those statistics that can be obtained by not traversing through the threads chain for the process. |
| -n NameList | Specifies an alternative system name-list file in place of the default. The operating system does not use the -n flag because information is supplied directly to the kernel. |
| -o Format | Displays information in the format specified by the
Format variable. Multiple field specifiers can be specified for the
Format variable. The
Format variable is either a comma-separated list of field specifiers or a list of field specifiers enclosed within a set of " " (double-quotation marks) and separated from one another by a comma or by one or more spaces, or both.
Each field specifier has a default header. The default header can be overridden by appending an = (equal sign) followed by the user-defined text for the header. The fields are written in the order specified on the command-line in column format. The field widths are specified by the system to be at least as wide as the default or user-defined header text. If the header text is null (such as if -o user= is specified), the field width is at least as wide as the default header text. If all header fields are null, no header line is written. The following field specifiers are recognized by the system:
|
| -o Continued |
|
| -o Continued |
Otherwise, multiple fields in a specified format can be displayed by the Format variable, including field descriptors. If field descriptors are used in the Format variable, it must be enclosed in double quotation marks (" "). The following table shows how field descriptors correspond to field specifiers: |
|
|
Each field specifier has a default header. The default header can be overridden by appending an equal sign (=) followed by the user-defined text for the header. The fields are written in the order specified on the command-line in column format. The field widths are specified by the system to be at least as wide as the default or user-defined header text. If the header text is null (for example,
|
|
|
Following is the mapping between the default headers and various field specifiers. Every entry in the Default Header column can be overridden by appending an equal sign (=) to the corresponding entry in the Field specifier followed by the user-defined text for the header.
|
| -p Plist | Displays only information about processes with the process numbers specified for the Plist variable. The Plist variable is either a comma-separated list of process ID numbers or a list of process ID numbers enclosed in double quotation marks (" ") and separated from one another by a comma or by one or more spaces, or both. |
| -P | Displays the Project name, Project origin, and subproject identifier for the project. If the stick bit is set for the process, the project name is preceded by an asterisk (*) character. The Project origin field designates the currently loaded project repository (LOCAL or LDAP). |
| -t Tlist | Displays only information about processes associated with the controlling ttys listed in the Tlist variable. The Tlist variable is either a comma-separated list of tty identifiers or a list of tty identifiers enclosed in double quotation marks (" ") and separated from one another by a comma or by one or more spaces, or both. |
| -T pid | Displays the process hierarchy rooted at a given pid in a tree format using ASCII art. This flag can be used in combination with the -f, -F, -o, and -l flags. |
| -u Ulist | This flag is equivalent to the -U Ulist flag. The -u flag only applies to the current operating environment unless the -@ flag is also specified. If the -@ flag is used to specify a workload partition other than the current operating environment and the -u flag is specified, the list of user IDs must be numeric. |
| -U Ulist | Displays only information about processes with the user ID numbers or login names specified for the Ulistvariable. The Ulist variable is either a comma-separated list of user IDs or a list of user IDs enclosed in double quotation marks (" ") and separated from one another by a comma and one or more spaces. The -Uflag only applies to the current operating environment unless the -@ flag is also specified. If the -@ flag is used to specify a workload partition other than the current operating environment and the -U flag is specified, the list of user IDs must be numeric. In the listing, the ps command displays the numerical user ID unless the -f flag is used; then the command displays the login name. This flag is equivalent to the -u Ulist flag. See also the u flag. |
| -X | Prints all available characters of each user/group name instead of truncating to the first eight characters. |
| -Z | Displays the page size settings of processes.
|
| -@ [ WparName ] | Displays the process information that is associated with the workload partition WparName. If you do not specify the WparName parameter, the process information for all workload partitions is displayed. Workload partition information is displayed for all processes. You must specify other flags to the ps command to determine which process information to be displayed. |
The following options are not preceded by a minus sign (-):
|
Item |
Description |
|---|---|
| a | Displays information about all processes with terminals (ordinarily only the own processes of the user are displayed). |
| c | Displays the command name, as stored internally in the system for purposes of accounting, rather than the command parameters, which are kept in the process address space. |
| e | Displays the environment as well as the parameters to the command, up to a limit of 80 characters. |
| ew | Wraps the display from the e flag one extra line. |
| eww | Wraps the display from the e flag and displays the ENV list until the flag reaches the LINE_MAX value. |
| ewww | Wraps the display from the e flag and displays the ENV list until the flag reaches the INT_MAX value. |
| g | Displays all processes. |
| l | Displays a long listing having the F, S, UID, PID, PPID, C, PRI, NI, ADDR, SZ, PSS, WCHAN, TTY, TIME, and CMD fields. |
| n | Displays numerical output. In a long listing, the WCHAN field is printed numerically rather than symbolically. In a user listing, the USER field is replaced by a UID field. |
| s | Displays the size (SSIZ) of the kernel stack of each process (for use by system maintainers) in the basic output format. This value is always 0 (zero) for a multi-threaded process. |
| t tty | Displays processes whose controlling tty is the value of the tty variable, which should be specified as printed by the ps command; that is, 0 for terminal /dev/tty/0, lft0 for /dev/lft0, and pts/2 for /dev/pts/2. |
| u | Displays user-oriented output. This includes the USER, PID, %CPU, %MEM, SZ, RSS, TTY, STAT, STIME, TIME, and COMMANDfields. |
| v | Displays the PGIN, SIZE, RSS, LIM, TSIZ, TRS, %CPU, %MEM fields. |
| w | Specifies a wide-column format for output (132 columns rather than 80). If repeated, (for example, ww), uses arbitrarily wide output. This information is used to decide how much of long commands to print. |
| x | Displays processes without a controlling terminal in addition to processes with a controlling terminal. |
| X | Prints the full user name or group name. The name is not truncated. |
This command returns the following exit values:
|
Item |
Description |
|---|---|
| 0 | Successful completion. |
| >0 | An error occurred. |
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.
|
Item |
Description |
|---|---|
| / usr/ bin/ ps | Contains the ps command. |
Using the ps command in Performance management.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29487349/viewspace-2767967/ ,如需转载,请注明出处,否则将追究法律责任。