1. Introduction
-
PS
It isLinux
one of the system commands, andLinux
it is the command to view the process in . See whatRunning
processes are running at . -
linux
5
There are states of the above process :运行
: running or waiting in the run queue中断
: Dormant, blocked, waiting for a condition to form or receive a signal不可中断
: Received signal does not wake up and cannot run, the process must wait until an interrupt occurs僵死
: The process has terminated, but the process descriptor exists untilwait4()
released after the parent process calls the system call停止
: The process stops running after receivingSIGSTOP
,SIGSTP
,SIGTIN
, signalsSIGTOU
-
view all processes
$ ps aux
-
kill specified process
$ sudo kill -9 PID PID ....
-
Filter to find the specified process
$ ps -aux | grep mysql
2. Property introduction
-
List of common attributes
# 显示现行终端机下的所有程序,包括其他用户的程序。 $ ps a # 显示所有程序。 $ ps -A # 列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。 $ ps c # 此参数的效果和指定 "A" 参数相同。 $ ps -e # 列出程序时,显示每个程序所使用的环境变量。 $ ps e # 用 ASCII 字符显示树状结构,表达程序间的相互关系。 $ ps f # 显示树状结构,表示程序间的相互关系。 $ ps -H # 显示所有的程序,除了执行ps指令终端机下的程序之外。 $ ps -N # 采用程序信号的格式显示程序状况。 $ ps s # 列出程序时,包括已中断的子程序资料。 $ ps S # 指定终端机编号,并列出属于该终端机的程序的状况。 $ ps -t <终端机编号> # 以用户为主的格式来显示程序状况。 $ ps u # 显示所有程序,不以终端机来区分。 $ ps x # 较长,较详细的显示该PID的信息 $ ps -l
-
$ ps -lA | more
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 4 S 0 1 0 0 76 0 - 1193 109952 ? 00:00:03 init 1 S 0 2 1 0 -40 - - 0 migrat ? 00:00:03 migration/0 1 S 0 3 1 0 94 19 - 0 ksofti ? 00:00:00 ksoftirqd/0 1 S 0 4 1 0 -40 - - 0 migrat ? 00:00:02 migration/1 1 S 0 5 1 0 94 19 - 0 ksofti ? 00:00:00 ksoftirqd/1 1 S 0 6 1 0 -40 - - 0 migrat ? 00:00:02 migration/2 1 S 0 7 1 0 94 19 - 0 ksofti ? 00:00:00 ksoftirqd/2
The meaning of the relevant fields above:
F
: The flag of the process(flag)
,4
indicating that the user is a super userS
: The state of the process(stat)
,STAT
the meaning of each see belowPID
: of the processID
C
:CPU
Percentage of resources usedPRI
:priority
(abbreviation for priority)NI
:NICE
The value of the process, the larger the value, the less CPU time it takesADDR
: The core function, pointing out the part of the process in the memory, if it is a running process, it is generally-
SZ
: the size of the memory usedWCHAN
: Whether the current process is running, if it-
is runningTTY
: terminal position of the registrantTIME
: CPU time usedCMD
: the command executed -
$ ps aux | more
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 4772 564 ? S Sep22 0:03 init [3] root 2 0.0 0.0 0 0 ? S Sep22 0:03 [migration/0] root 3 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/0] root 4 0.0 0.0 0 0 ? S Sep22 0:02 [migration/1] root 5 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/1] root 6 0.0 0.0 0 0 ? Ss+ Sep22 0:02 [migration/2] root 7 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/2] root 8 0.0 0.0 0 0 ? S Sep22 0:00 [migration/3] root 9 0.0 0.0 0 0 ? SN Sep22 0:00 [ksoftirqd/3] root 10 0.0 0.0 0 0 ? S< Sep22 0:00 [migration/4]
The meaning of the relevant fields above:
USER
: the owner of the processPID
: ID of the processPPID
: parent process%CPU
: CPU percentage used by the process%MEM
: Percentage of occupied memoryNI
:NICE
The value of the process, the larger the value, the lessCPU
time it takesVSZ
: Amount of virtual memory used by the process (KB)RSS
: Amount of fixed memory (KB) occupied by the process (number of resident pages)TTY
: The terminal on which the process is running (the terminal location of the registrant), if it has nothing to do with the terminal, it will display (?), if it is pts/0, etc., it means that the host process is connected by the networkWCHAN
: Whether the current process is in progress, if it is - means it is in progressSTART
: The process was triggered to start the timeTIME
: The time the process actually uses the CPU to runCOMMAND
: The name and arguments of the commandSTAT
: Common status characters for status bitsD
: Uninterruptible sleep state (normalIO
process)R
running available in queue available for passingS
: dormantT
: stop or be trackedW
: enter memory swap (2.6
not valid from kernel onwards)X
: dead process (basically rare)Z
: zombie process<
: high priority processN
: lower priority processL
: Some pages are locked into memorys
: the leader of the process (with child processes under it)l
: multiprocess (useCLONE_THREAD
, similarNPTL pthreads
)+
: a process group that sits in the background