PS Command Usage detailed

Source: Internet
Author: User

PS is a tool used in Linux to view the various information of the process, through the PS command we can very clearly grasp the various processes used by the system resources, timely detection of those resource consumption of abnormal processes. Ensure high availability and stability of server systems.

System environment: Debian Gnu/linux 7.7 (wheezy)
Pathname:/bin/ps
Package:procps

PS Command options: Simple process selection:

-A Select all processes
-e selects all processes, equivalent to-a

Select a process from the list (process SELECTION by list)

-C Cmdlist
Select a process by the name of the process's executable file

Output format Control:

-l--long format, the-y option is useful when combined with this
-o--custom output format, followed by format specifier (separated by commas between format specifiers)
-y--does not show flags and displays RSS instead of addr, this option can only be used with the-l option

Output modifier (MODIFIERS):

--no-headers--not print head
--sort spec--Specifies the sort order, by default in ascending order by spec (specifier) (+spec: In the spec ascending order;-spec, sorted by spec descending)

Standard format specifier:

Code Head Describe
%mem %MEM Percentage of process consuming physical memory
Args COMMAND Output command and all its parameters
Cmd Cmd Alias args
Comm COMMAND Output only the name of the executable file
Command COMMAND Alias args
ETime ELAPSED The run time of the output process, the time format is as follows: [[[Dd-]hh:]mm:ss] does not show dd-for more than one day, if the run time is less than one hour, the display format is MM:SS
Euser Euser The user name of the performer of the output process (sometimes the UID of the performer is displayed)
Lstart STARTED Output Process Start time
Pid Pid Process number of the output process
Psr Psr Process is currently assigned the processor
Pmem %MEM Alias%mem
Rss Rss Use size of physical memory in kilobytes (KB)
Rssize Rss Alias RSS
Rsz Rsz Alias RSS
S S Minimum status display (only one character is displayed)
Stat STAT Multi-character status display (more detailed process status information is displayed)
State S Alias S
Uname USER Alias Euser
User USER Alias Euser

Process Status Code:
D Non-disruptive sleep
R is running or can be run (or in the running queue)
S can interrupt sleep
T is terminated
X is dead (should never be seen)
Z deceased process, terminated but not reclaimed by its parent process
< high priority (unfriendly to other users)
N Low priority (for other user-friendly)
L page locked in memory
s contains sub-processes (is a session leader)
L Multithreading
+ located in the foreground process group

[Email protected]:~# ps-eo Rss,pid,user,etime,lstart,stat,args--no-headers |sort-k 1-nr
Sort by the first parameter RSS (physical memory) usage from large to small

Sort in ascending order by RSS size
# PS-LYC PHP5-FPM--sort RSS
S UID PID PPID C PRI NI RSS SZ Wchan TTY time CMD
S 0 18303 1 0 80 0 508 10460-? 00:00:03 PHP5-FPM
S 33 22675 18303 1 80 0 39040 18523-? 00:00:04 PHP5-FPM
S 33 22676 18303 0 80 0 42576 19404-? 00:00:03 PHP5-FPM
S 33 22435 18303 0 80 0 47904 20698-? 00:00:19 PHP5-FPM

Note: When the-o option is used with--no-headers, the--no-headers needs to be placed behind the format specifier

http://godontop.com/linux-ps-command-usage-69/

Ps-elo Pid,tid,class,rtprio,ni,pri,psr,pcpu,pmem,stat,wchan:30,comm
-E Show All processes
-L is the real thread information
-O means printing information using user-defined formats

TID indicates thread ID
PCPU indicates CPU usage

Pmem Reference%cpu
%CPU%CPU CPU utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as A
Percentage. It won't add to 100% unless is lucky. (alias Pcpu).
Pmem Reference%mem
%mem%mem ratio of the process ' s resident set size to the physical memory on the machine, expressed as a Percentag E. (alias Pmem).

WCHAN:30 Wchan name of the kernel function in which the process was sleeping, a "-" if the process is running, or a "*" if The process is multi-threaded and PS are not displaying threads.

The Program Status field explains:

D uninterruptible sleep (usually IO) non-disruptive
R Running or runnable (on run queue) is executing or executable, indicating that it is currently running in the queue
S interruptible sleep (waiting for a event to complete) sleeps interrupted
T Stopped, either by a job control signal or because it is being traced. Stop
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. Zombie Process

For BSD formats and when the STAT keyword are used, additional characters may be displayed: additional fields
< High-priority (not nice-to-other users) high priority
N low-priority (Nice-to-other users) low priority
L have pages locked to memory (for real-time and custom IO)
S is a session leader
L was multi-threaded (using Clone_thread, like NPTL pthreads do)
+ is in the foreground process group

Http://blog.chinaunix.net/uid-21706718-id-3341751.html

ps Command usage explanation (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.