Shell View process Status--ps command

Source: Internet
Author: User
Tags sort

Http://www.cnblogs.com/wangkangluo1/archive/2011/09/23/2185938.html


Name: PS
Usage rights: All users
How to use: PS [options] [--help]
Description: Shows the dynamics of the instantaneous stroke (process)
Parameters: The parameters of PS are very many, only a few common parameters are listed here and the meaning
-A lists all processes
-W display widen to show more information
-au Show more detailed information
-aux Show all itineraries that contain other users

############################################################

Common parameters:

-A show all processes (equivalent to-e) (utility)
-a displays all processes of a terminal, in addition to session leader
-N ignores selection.
-D displays all processes, but omits all session leaders (utility)
-X displays a process that does not control the terminal, and displays the specific path of each command. DX cannot be combined. (utility)
-p PID process uses CPU time
-U uid or username Select a valid user ID or user name
-G gid or groupname displays all processes for the group.
U username Displays all processes under the user, and displays the detailed path of each command. such as: PS U Zhang; (utility)
-F is all listed, and is usually used with other options. such as: Ps-fa or Ps-fx and so on.
-L long format (with fields such as F,wchan,c)
-J Job Format
-o user-defined format.
V display in virtual memory format
s displayed in signal format
-M Show All threads
-H displays the level of the process (shared with other commands, such as: ps-ha) (utility)
The e command then displays the environment (for example: ps-d e; Ps-a e) (utility)
H does not display the first line

############################################################

ps Command common usage (easy to view system process)

1) PS A shows all the programs under the current terminal, including other users ' programs.
2) ps-a Show all processes.
3) PS C lists the program, displays the actual instruction name of each program, and does not include the path, parameter or the indication of the resident service.
4) Ps-e The effect of this parameter is the same as specifying the "A" parameter.
5) When listing the program, PS e displays the environment variables used by each program.
6) PS F Displays the tree structure with ASCII characters, expressing the relationship between the programs.
7) ps-h shows the tree structure, indicating the relationship between the programs.
8) Ps-n shows all the programs except the program under the PS Command Terminal.
9) PS s uses the program signal format to display the program status.
PS S when listing programs, including interrupted sub-program data.
ps-t< Terminal number > Specify the terminal number, and list the status of the program belonging to the terminal.
PS U Displays the status of the program in a user-oriented format.
PS x Displays all programs and does not differentiate by terminal.
The most common approach is to Ps-aux, and then use a pipe symbol to direct to grep to find a specific process and then manipulate the specific process.


Example:
View the uid,pid,stat,pri of the current system process, sorted by UID number.
Ps-eo Pid,stat,pri,uid–sort UID

View the User,pid,stat,rss,args of the current system process, sorted by RSS.
Ps-eo User,pid,stat,rss,args–sort RSS

############################################################

PS gives us a one-time view of the process, it provides a view of the results is not dynamic continuous, if you want to monitor the process, you should use the top tool.


1, PS parameter description:

PS offers a number of options parameters, commonly used in the following several:

l long format output;
U displays the process in the order of the user name and start time;
J Use the task format to display the process;
F to display the process in a tree-shaped format;

A shows all processes of all users (including other users);
X shows the process without control terminal;
R shows the running process;
WW avoids detailed parameters being truncated;

Our common options are the combination of aux or lax, and the application of parameter F.


2. Explanation of PS aux or lax output:

Owner of the USER process;
The ID of the PID process;
PPID parent process;
Percentage of CPU consumed by the%CPU process;
%MEM% of memory occupied;
The nice value of the NI process, which is large, means that it consumes less CPU time;
VSZ process virtual size;
The number of pages that RSS resides in;
TTY Terminal ID
STAT process status (with the following types)
D a dormant state (usually IO process) that cannot be interrupted;
R is running can be in the queue can be too line;
S is in a dormant state;
T stop or be traced;
W enters memory swap (invalid starting from kernel 2.6);
X dead process (never seen);
Z Zombie process;

< high-priority processes
N Low-priority processes
L Some pages are locked into memory;
Leader of the S-process (under it there are sub-processes);
L multi-process (using Clone_thread, similar to NPTL pthreads);
+ Process Group located in the background;
Wchan the process resources being awaited;
Start START process time;
The time the process consumes the CPU;
The name and parameters of the command commands;


3, Application Examples:

[Root@localhost ~]# Ps-aux |more
Can be used | The pipe and more are linked up for pagination viewing.
[Root@localhost ~]# ps-aux > Ps001.txt
Output the results to the Ps001.txt text and save them.
[Root@localhost ~]# more Ps001.txt
Here is the display of all the processes, and output to the Ps001.txt file, and then through more to Page view.


4, kill kills the process, there are more than 10 ways to control the process, the following are some common methods:
[root@localhost ~] #kill-stop [PID]
Send Sigstop (17,19,23) to stop a process without destroying it.
[root@localhost ~] #kill-cont [PID]
Send Sigcont (19,18,25) to restart a stopped process.
[root@localhost ~] #kill-kill [PID]
Send Sigkill (9) forces the process to stop immediately and does not implement a cleanup operation.
[root@localhost ~] #kill-9-1
Stop all the processes you have.

Related Article

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.