ps - report process status
ps [–aAcdefHjlLPwWyZ] [–C cmdlist] [–g pgrplist|grouplist] [–h|–lgroup lgrplist] [–n namelist] [–o|–format format]… [–O format]… [–p|–pid proclist] [–pgid pgrplist] [–ppid proclist] [–s|–sid sidlist] [–t|–tty termlist] [–u|–user uidlist] [–U|–User uidlist] [–group gidlist] [–G|–Group gidlist] [–z zonelist] [–columns|–cols|–width columns] [–lines|–rows lines] [–headers] [–no-headers|–no-heading] [–human-readable] [--scale[=item1,item2,...]] [–?|–help]
ps [–aceglnrSuUvwx] [ -t term] [--scale[=item1,item2,...]] [num]
The ps command prints information about active processes. Without options, ps prints information about processes that have the same effective user ID and the same controlling terminal as the invoker, and the output contains only the process ID, terminal identifier, cumulative execution time, and the command name. Otherwise, the information that is displayed is controlled by the options.
A number of options are provided to select the processes to list. If any of these options are specified, the processes listed are determined by the inclusive OR of processes selected by the specified options. When the –A or –e option is specified, other options to select processes by more selective criteria have no effect, and are unnecessary.
Some options accept lists as arguments. Items in a list can be either separated by commas or else enclosed in quotes and separated by commas or spaces. Repeated options are allowed. Each option adds additional items to the list. Values for lgrplist, proclist, pgrplist, and sidlist must be numeric.
The following options are supported:
List information about all processes most frequently requested: all those except session leaders and processes not associated with a terminal.
List information for all processes.
Print information in a format that reflects scheduler properties as described in priocntl(1) man page. The –c option affects the output of the –f and –l options, as described below.
List information for processes for which the name of the command is listed in cmdlist. Only reports processes for which the full base name of the command matches the given string. It does not perform substring matches or include path names. For more complex matching operations, see pgrep(1) and Example 4 below.
List information about all processes except session leaders.
List information about every process now running. Identical to –A, above, but less portable as only –A is specified by the POSIX standard.
Generate a full listing. See DISPLAY FORMATS below.
The –g option provides a hybrid of the –pgid and –group options, using heuristics to determine whether the argument refers to process groups or user groups. If all argument values are numeric, the behavior is that of –pgid, providing the traditional Solaris behavior of matching by process groups. If any argument value contains an alphabetic character, –g instead provides the behavior of the –group option, for compatibility with the behavior of ps on other platforms. Multiple instances of –g are allowed. The determination of which behavior to provide is made independently for each instance of the –g, and is applied to all values provided for that instance.
List information for processes whose effective group ID numbers are given by gidlist.
List information for processes whose real group ID numbers are given by gidlist.
List information for processes homed to the specified lgrplist. Nothing is listed for any invalid group specified in lgrplist.
Print the home lgroup of the process under an additional column header, LGRP. This column can also be enabled by specifying the lgrp name with the –o or –O options.
Print session ID and process group ID. These columns can also be enabled by specifying the pgid and sid names with the –o or –O options.
Generate a long listing. See DISPLAY FORMATS below.
Print information about each light weight process (lwp) in each selected process. See DISPLAY FORMATS below.
This option is accepted for compatibility, but is ignored.
Format displayed information according to the format specification given by format. See DISPLAY FORMATS. Multiple –o or –format options can be specified; the format specification is interpreted as the space-character-separated concatenation of all the format option-arguments.
Identify additional fields to be added, removed, or modified from the default output. The format argument is the same as that accepted by the –o option. See DISPLAY FORMATS. Prepend the format specifier with a - character to remove that field rather than add it. In the case of a field already already present in the output format, the new header and width take precedence.
List information for processes whose process ID numbers are given by proclist.
List information for processes with the group leader ID number(s) given by pgrplist. A group leader is a process whose process ID number is identical to its process group ID number.
List information for processes with the parent process ID number(s) given by proclist.
Print the number of the processor to which the process or lwp is bound, if any, under an additional column header, PSR. This column can also be enabled by specifying the psr name with the –o or –O options.
List information for processes whose session ID numbers are specified by sidlist.
List information for processes associated with term. Terminal identifiers are specified as a device file name, and an identifier. For example, term/a, or pts/0.
List information for processes with the effective user ID number or login name given by uidlist.
List information for processes with the real user ID numbers or login names given by uidlist.
The –w option overrides output line length. Specify –w once to truncate lines at 132 characters of output. Specify –w two or more times to allow unlimited line length without truncation. See DISPLAY WIDTH.
Reset the display column width to the default, overriding any preceding –w, –columns, –cols, or –width options. See DISPLAY WIDTH.
Alter the long listing format displayed by the –l option to omit the obsolete F and ADDR columns, to include an RSS column to report the resident set size of the process in kilobytes, and to modify the SZ column to display in units of kilobytes rather than pages. See DISPLAY FORMATS.
List information for processes in the specified zones. Zones can be specified either by name or ID. This option is only useful when executed in the global zone.
Print the name of the zone with which the process is associated under an additional column header, ZONE. The ZONE column width is limited to 8 characters. Use ps –eZ for a quick way to see information about every process now running along with the associated zone name. Use
ps -o zone,uid,pid,ppid,time,comm,...
to see zone names wider than 8 characters.
Specify the number of columns, overriding the COLUMNS environment variable. See DISPLAY WIDTH.
Display per-page headers. Page size is determined as follows, listed in order of priority.
The last specified value of either a –lines or –rows option on the command line.
The LINES environment variable.
If output or input is a tty, the tty height.
Omit the column headers from the output.
Specify the number of rows per page of output, overriding the LINES environment variable. See the –headers option for details.
Print memory sizes scaled to a human readable format, instead of as raw numbers of pages or kilobytes. The –human-readable option is equivalent to using the –scale=max,1024 option.
Print memory sizes scaled to a human readable format, instead of as raw numbers of pages or kilobytes. For example, 14K, 234M, 2.7G, or 3.0T. Scaling is done by repetitively dividing the number of bytes by 1024, unless otherwise specified.
–scale specified without arguments enables default scaled output, and is equivalent to –scale=max,1024.
–scale can be specified with the following arguments.
Scaling is done by repetitively dividing by a scale factor of 1024. The use of binary scaling is indicated by the addition of an 'i' modifier to the suffix (Ki, Mi, Gi, ...).
Values are scaled to the largest unit for which the result retains a non-zero integer part. Up to 2 decimal places of fractional output may be shown.
Values are scaled to the smallest unit capable of showing the full value within the allotted space of 5 columns, and displayed without the use of fractional output.
Values are scaled to the smallest unit capable of showing the full value within the allotted space of 8 columns, and displayed without the use of fractional output.
Scaling is done by repetitively dividing by a scale factor of 1000.
Scaling is done by repetitively dividing by a scale factor of 1024.
Print the usage synopsis and exit without doing anything else.
Previous versions of Oracle Solaris provided an alternative ps command, /usr/ucb/ps, derived from BSD UNIX. The UCB version of ps is no longer part of Oracle Solaris. Instead, the standard ps command provides an emulation of UCB ps behavior when the following UCB options are specified. The UCB options are not prefixed with a hyphen (–) character, distinguishing them from the standard options described previously. Standard and UCB options cannot be mixed in a single ps invocation.
Includes information about processes owned by others.
Displays the command name rather than the command arguments.
Displays the environment as well as the arguments to the command.
Displays all processes. Without this option, ps only prints interesting processes. Processes are deemed to be uninteresting if they are process group leaders. This normally eliminates top-level command interpreters and processes waiting for users to login on free terminals.
Displays a long listing, with fields F, PPID, CP, PRI, NI, SZ, RSS, and WCHAN as described below.
Produces numerical output for some fields. In a user listing, the USER field is replaced by a UID field.
Restricts output to running and runnable processes.
Displays accumulated CPU time used by this process and all of its reaped children.
List information for processes associated with the terminal, term. Terminal identifiers may be specified in one of two forms: the device's file name (for example, tty04 or term/14) or, if the device's file name starts with tty, just the digit identifier (for example, 04).
Displays user-oriented output. This includes fields USER, %CPU, %MEM, SZ, RSS, and START as described below.
Obsolete. This option no longer has any effect. It causes ps to exit without printing the process listing.
Displays a version of the output containing virtual memory. This includes fields SIZE, %CPU, %MEM, and RSS described below.
Uses a wide output format, that is, 132 columns rather than 80. If the option letter is repeated, that is, –ww, this option uses arbitrarily wide output. This information is used to decide how much of long commands to print.
Includes processes with no controlling terminal.
A process number may be given, in which case the output is restricted to that process. This option must be supplied last.
Under the –L option, or when lwp-specific columns are specified for the –o option, one line is printed for each lwp in the process and the time-reporting fields STIME and LTIME show the values for the lwp, not the process. A traditional single-threaded process contains only one lwp.
A process that has exited and has a parent, but has not yet been waited for by the parent, is marked <defunct>.
The –o option allows the output format to be specified under user control.
The format specification must be a list of names presented as a single argument, blank- or comma-separated. Each variable has a default width and header. The default width can be overridden by adding a colon followed by a number but it will be ignored if it is smaller than the minimum width of that column. If a double colon is used instead and it is applied to the last column, the field will be truncated to that width. The default header can be overridden by appending an equals sign and the new text of the header. The rest of the characters in the argument is used as the header text. The fields specified are written in the order specified on the command line, and should be arranged in columns in the output. The field widths are selected by the system to be at least as wide as the header text (default or overridden value). If the header text is null, such as –o user=, the field width is at least as wide as the default header text. If all header text fields are null, no header line is written.
The following names are defined by the POSIX standard:
The effective user ID of the process. This is the textual user ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
The real user ID of the process. This is the textual user ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
The effective group ID of the process. This is the textual group ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
The real group ID of the process. This is the textual group ID, if it can be obtained and the field width permits, or a decimal representation otherwise.
The decimal value of the process ID.
The decimal value of the process ID of the parent process.
The decimal value of the process ID of the process group leader.
The ratio of CPU time used recently to CPU time available in the same period, expressed as a percentage. The meaning of “recently” in this context is unspecified. The CPU time available is determined in an unspecified manner.
The total size of the process in virtual memory, in kilobytes.
Nice value, used in priority computation. Only processes in certain scheduling classes have a nice value. See the nice(1) man page.
The elapsed time since the process was started. In the POSIX locale, has the form:
[[dd-] hh:]mm:ss
where
is the number of days
is the number of hours
is the number of minutes
is the number of seconds
The dd field is a decimal integer. The hh, mm and ss fields are two-digit decimal integers padded on the left with zeros.
The cumulative CPU time of the process or LWP. In the POSIX locale, has the form:
[dd-]hh:mm:ss
The dd, hh, mm, and ss fields are as described in the etime specifier.
The name of the controlling terminal of the process (if any) in the same format used by the who(1) command. ? is printed for processes with no controlling terminal.
The name of the command being executed (argv[0] value) as a string.
The command with all its arguments as a string. The Oracle Solaris implementation does not limit the length of the string, but may truncate the displayed string as described in DISPLAY WIDTH. The string is the version of the argument list as it was passed to the command when it started. Applications cannot depend on being able to modify their argument list and having that modification be reflected in the output of ps.
The following names are additionally recognized in the Oracle Solaris implementation:
Flags (hexadecimal and additive) associated with the process. These flags are available for historical purposes; no meaning should be currently ascribed to them.
The state of the process:
Process is running on a processor.
Sleeping: process is waiting for an event to complete.
Runnable: process is on run queue.
Process is stopped, either by a job control signal or because it is being traced.
Waiting: process is waiting for CPU usage to drop to the CPU-caps enforced limits.
Zombie state: process terminated and parent not waiting.
Processor utilization for scheduling (obsolete).
The effective user ID number of the process as a decimal integer.
The real user ID number of the process as a decimal integer.
The saved user ID number of the process as a decimal integer. "?" will be displayed for any process for which ps does not have privileges to open /proc/pid/cred.
The saved user ID of the process. This is the textual user ID, if it can be obtained and the field width permits, or a decimal representation otherwise. "?" will be displayed for any process for which ps does not have privileges to open /proc/pid/cred.
The effective group ID number of the process as a decimal integer.
The real group ID number of the process as a decimal integer.
The saved group ID number of the process as a decimal integer. "?" will be displayed for any process for which ps does not have privileges to open /proc/pid/cred.
The saved group ID of the process. This is the textual group ID, if it can be obtained and the field width permits, or a decimal representation otherwise. "?" will be displayed for any process for which ps does not have privileges to open /proc/pid/cred.
The project ID number of the process as a decimal integer.
The project ID of the process as a textual value if that value can be obtained; otherwise, as a decimal integer.
The zone ID number of the process as a decimal integer.
The zone ID of the process as a textual value if that value can be obtained; otherwise, as a decimal integer.
The decimal value of the process ID of the session leader.
The task ID of the process.
The scheduling class of the process. See the USAGE section of the priocntl(1) man page for information on scheduling classes.
The priority of the process for the scheduler used in Solaris 2.0 and later releases. Higher numbers mean higher priority.
The obsolete priority of the process displayed as used in the SunOS 4.x scheduler. Lower numbers mean higher priority.
The decimal value of the lwp ID. Requesting this formatting option causes one line to be printed for each lwp in the process.
The thread name of the lwp ID. Requesting this formatting option causes one line to be printed for each lwp in the process.
The number of lwps in the process.
The number of the processor to which the process or lwp is bound.
The ID of the processor set to which the process or lwp is bound.
The memory address of the process. If not running with all privileges, 0 will be printed.
The total size of the process in virtual memory, including all mapped files and devices, in pages. See pagesize(1).
The address of an event for which the process is sleeping (if −, the process is running). Only visible when running with all privileges, otherwise it is 0. To determine if a process is sleeping, check the S column.
The elapsed time since the process was started, in seconds.
The cumulative CPU time of the process, in seconds.
The starting time or date of the process. If less than 24 hours ago, the time is printed as the hour, minute, and second. If at least 24 hours ago, the date is printed as month and day. If specified as –o stime, printed with no blanks. If enabled via the –f option, dates will have a space between the month and day.
The data model of the process, _LP64 or _ILP32.
The resident set size of the process, in kilobytes. The rss value reported by ps is an estimate provided by proc(5) that might underestimate the actual resident set size. Users who wish to get more accurate usage information for capacity planning should use pmap(1) –x instead.
The resident set size of the process, in kilobytes, of the private, non-shared mappings.
The resident set size of the process, in kilobytes, of the non-private, shared mappings. The sum of rssshared and rssprivate equals rss.
The ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage.
The base name of the process's executable file.
The contract ID of the process contract the process is a member of as a decimal integer.
The home lgroup of the process.
The initial environment of the process.
The SMF FMRI corresponding to the contract id.
If Solaris Trusted Extensions is in use, the label for the process, otherwise the clearance for the process. See labels(7) and clearance(7) for more information.
Only comm, args, lname, env, and label are allowed to contain blank characters; all others, including the Oracle Solaris implementation formats, are not. Columns in the output formats specified by options other than –o may contain blank characters. Use –o when parsing output to avoid this.
The Oracle Solaris implementation also accepts the following aliases to the above specified format specifiers:
|
The following table specifies the default header to be used in the POSIX locale corresponding to each format specifier defined by the POSIX standard.
|
The following table lists the Oracle Solaris implementation format specifiers and the default header used with each.
|
The default headers are not currently localized in the Oracle Solaris implementation, but may be in other implementations, including future updates to Oracle Solaris. The header strings shown here will always be used in the C or POSIX locales, regardless of any localization in other locales.
Prior to the addition of the –o option, the ps command accepted a number of options to specify which columns to print. Those options are still supported, but can also be mapped to equivalent –o formats as follows. Column widths may differ from the listed formats.
The historical options print slightly different time formats than the listed format operands. The historical format for time only displays minutes and seconds in hh:mm format, while the time operand will display days, hours, minutes, and seconds if necessary. For processes that are at least 24 hours old, the historical format for stime has a space between the month and day, while the stime operand prints an underscore (_) between the month and day.
pid,tty,time,fname=CMD
If per-lwp display is enabled, the title of the time column is changed to LTIME.
Add user,ppid,c,opri,nice,stime. Replace fname=CMD with args=CMD.
Add f,s,uid,ppid,c,opri,nice,addr,osz,wchan.
If output is to a tty and the ps command is run without sufficient privileges to retrieve kernel addresses, omit addr and wchan.
If both –f and –l are specified, omit uid and include user.
Add class,pri.
Modify –f to remove c.
Modify –l to remove c,opri,nice.
Add lgrp.
Add pgid,sid
Add lwp,lname and enable per-lwp display. If –f is also specified, also add nwlp.
Add psr.
Modify –l to remove f and addr, replace osz with vsz, and add rss.
Add zone:8.
By default, lines are limited to the columns setting. If any of the –columns, –cols, or –width options are used, the columns setting is the value from the last one of those options on the command line. If none of those options are provided, the value of the COLUMNS environment variable is used for the columns setting. If neither of the options or environment variable are specified, then if the output is a tty, the terminal width is used for the columns setting, otherwise the value of LINE_MAX is used.
When the –w option is specified exactly once, lines are limited to 132 characters of output.
When the –w option is specified two or more times, lines are unlimited in length. Applications and scripts which pipe the output of ps to another command should use care with this option, as some programs may be limited to handling only LINE_MAX characters per line.
The command:
example% ps -o user,pid,ppid=MOM -o args
writes the following in the POSIX locale:
USER PID MOM COMMAND helene 34 12 ps -o uid,pid,ppid=MOM -o argsExample 2 Using ps –O Option to add or modify fields
The command:
example% ps -u $USER -O tty:10,pcpu
writes the following in the POSIX locale:
PID TTY TIME %CPU CMD 8273 kz/term/1 0:00 0.0 ps 850 console 0:00 0.0 tcsh 7799 kz/term/1 0:00 0.0 tcshExample 3 Using ps –O Option to suppress fields
The command:
example% ps -u $USER -O -tty
writes the following in the POSIX locale:
PID TIME CMD 8273 0:00 ps 850 0:00 tcsh 7799 0:00 tcshExample 4 Using ps to display processes selected by pgrep
The pgrep command allows more options for selecting processes than ps, but is much more limited in the information it displays about each process. Combining them allows using the strengths of each command.
This command displays processes whose names match a regular expression, instead of the simple string match provided by ps –C.
example% ps -p `pgrep -d, 'gnome-.*-server'` PID TT TIME CMD 1665 ? 0:03 gnome-shell-calendar-server 1989 ? 15:46 gnome-terminal-server
See environ(7) man page for descriptions of the following environment variables that affect the execution of ps: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, LC_TIME, NLSPATH, and TZ.
Override the system-selected horizontal screen size, used to determine the number of text columns to display. See the description of the –w option for details.
Override the system-selected vertical size, used to determine the number of text rows per page of output. See the description of the –headers option for details.
The following exit values are returned:
Successful completion
An error occurred
list of terminal devices
terminal (“tty”) names searcher files
process control files
See attributes(7) for descriptions of the following attributes:
|
|
kill(1), lgrpinfo(1), nice(1), pagesize(1), pgrep(1), pmap(1), priocntl(1), proc(1), ptree(1), who(1), proc(5), ttysrch(5), attributes(7), environ(7), resource-controls(7), standards(7), zones(7), getty(8), prstat(8)
Things can change while ps is running. The snapshot it gives is true only for a split-second, and it might not be accurate by the time you see it. Some data printed for defunct processes is irrelevant.
If no options to select processes are specified, ps reports all processes associated with the controlling terminal. If there is no controlling terminal, there is no report other than the header.
ps –f or ps –o stime might not report the actual start of a tty login session, but rather an earlier time, when a getty was last respawned on the tty line.
On prior releases the ADDR and WCHAN fields might have contained the kernel memory address of the process and/or event it was waiting on. These fields are now always 0 unless requested by a process running with all privileges. The values can still be obtained using the ::ps and ::thread dcmds within mdb.
ps is CSI-enabled except for login names (usernames).
When run in the global zone, user and group name resolutions are done using the global zone's name services. Processes running in a non-global zone that are displayed by ps, have user and group names that match with those found in the global zone's name services, but they may differ from the name services configured in non-global zones.
While use of the –o option can allow for reliable parsing of ps output by scripts, programs can have more efficient access to the information reported via proc(5) interfaces. The following table shows which procfs interfaces are used to provide each ps output field.
|
In Solaris 2.0 through 10, a separate /usr/ucb/ps command was provided to support the UCB options. In Solaris 11.0, support for the UCB options was added to /usr/bin/ps, and /usr/ucb/ps was replaced with a link to /usr/bin/ps.
Command name and arguments output was limited to 80 characters until the introduction of /proc/pid/cmdline in Oracle Solaris 11.3.5.
Support for the following options was first added in the listed Oracle Solaris release:
|
Support for the following format specifiers was first added in the listed Oracle Solaris release:
|