Options & Arguments
ps [option]...
OPTION STYLE
- UNIX-style(-c),
- GNU-style(—dosomething),
- X-style(-dosomething)
- BSD-style(a) | Option Style | Option | Description | | —- | —- | —- | | BSD-style | a | 显示【所有用户】、【有 TTY】的进程
| | | x | 显示无论有无 TTY 的进程 | | | u | user-oriented output,
显示 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND 信息 | | | f | 使用树形结构(\_)格式化父子进程 | | | j | BSD job control format. | | UNIX-style | -e
-A | 显示所有进程,无论有无 TTY 的进程ps -e=ps ax| | | -f | full-format listing.
显示 UID PID PPID C STIME TTY TIME CMD | | | -j | Jobs format | | | -H | 树形结构(空格) | | GNU-style | —sort | —sort=[+|-]NAME…
根据 NAME 排序,+(升序,默认),-(降序), |
Colomn Fields
| Field | Meaning | |
|---|---|---|
| PID | Process ID | |
| TTY | teletype, controlling terminal for the process |
|
STAT |
State | Meaning |
| R | Running. This means the process is running or ready to run. | |
| S | Sleeping. The process is not running; rather, it is waiting for an event, such as a keystroke or network packet. |
|
| D | Uninterruptible sleep. The process is waiting for I/O such as a disk drive. | |
| T | Stopped. The process has been instructed to stop. You’ll learn more about this later in the chapter. | |
| Z | A defunct or “zombie” process. This is a child process that has terminated but has not been cleaned up by its parent. |
|
| < | A high-priority process. It’s possible to grant more importance to a process, giving it more time on the CPU. This property of a process is called niceness. A process with high priority is said to be less nice because it’s taking more of the CPU’s time, which leaves less for everybody else. | |
| N | A low-priority process. A process with low priority (a nice process) will get processor time only after other processes with higher priority have been serviced. |
|
| TIME | The amount of CPU time consumed by the process. | |
| CMD | Command. | |
| USER | User ID. This is the owner of the process. | |
| %CPU | CPU usage in percent. | |
| %MEM | Memory usage in percent. | |
| VSZ | Virtual memory size. | |
| RSS | Resident set size. This is the amount of physical memory (RAM) the process is using in kilobytes. |
|
| START | Time when the process started. For values over 24 hours, a date is used. |
Examples
Sort
postgres@VM-4-16-ubuntu:~$ ps aux --sort=-%cpu | head -6USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMANDpostgres 1249676 2.2 0.4 52412 16572 ? Sl 21:27 2:24 /usr/sbin/httpd 1 -f 1 -s 12 -S 6 -p 0 -d 1 p iproot 1513 0.6 1.8 1048040 75580 ? SLl 2021 228:08 /usr/local/qcloud/YunJing/YDEyes/YDServicesystemd+ 2447163 0.3 1.7 2324244 72472 ? Ssl Jan05 58:26 mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1 --bind_ip_allroot 1450 0.2 0.3 490940 14080 ? Sl 2021 98:24 barad_agent65533 2447481 0.2 18.2 3417812 734536 ? Sl Jan05 43:12 node main.js
