"Linux" PS command

Source: Internet
Author: User
Tags syslog egrep

The PS command in Linux is the abbreviation for Process Status . The PS command is used to list those processes that are currently running on the system. The PS command lists the current snapshots of those processes, which are those that are executing the PS command at the moment, and if you want to display process information dynamically, you can use the top command.

To monitor and control the process, you must first understand the current process, that is, you need to see the current process, and the PS command is the most basic and very powerful process view command. Use this command to determine which processes are running and running, whether the process is complete, if the process is zombie, which processes are consuming too many resources, and so on. In short, most of the information can be obtained by executing the command.

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.

PSPS - PS axjf parameter:-A: All process is shown, and-e has the same effect;-A : All process not related to terminal;-u: Effective user (effective user) related process; x: typically used with the A parameter to list more complete information. Output format planning: L: A longer, more detailed list of the PID information; J: Working format (jobs format)-PSmanPS Oh, whoa!

  Example 1: Make a list of the PID and related information that currently belongs to you in this login

[Email protected] ~]#PS-LF S UID PID PPID C PRI NI ADDR SZ wchan TTY time CMD0S0 5881 5654 0  the 0-1303 waitpts/0 xx:xx:xx su4S0 5882 5881 0  the 0-1349 waitpts/0 xx:xx:xxBash4R0 6037 5882 0  the 0-1111-pts/0 xx:xx:xx PS# The above information is actually a lot! The meaning of the relevant information is: # F represents the flag of this program,4representing the user as Super user;# S represents the status of this program (STAT), the meaning of each STAT will be introduced in the text; # PID no problem!? Is the ID of this program Ah! The PPID on the bottom is the percentage of resources used by the id;# C CPU of the parent program # PRI This is the abbreviation for priority (precedence order), described in detail later; # NI This is the nice value, and we'll continue to introduce it in the next section. # ADDR This is kernelfunction, indicating the part in which the program was stored. If it's a running program, it's usually "-"The!" # SZ used memory size; # Wchan Whether the program is currently in operation, if-the sign is running; # TTY Login's terminal location; # time used to run out of CPU. # CMD is the order of the orders!? # carefully see how the PID of each program correlates with PPID. Among the three programs listed above, there is a correlation between the two. 

  Example 2: List all currently in-memory programs

[Email protected] ~]#PSAuxuser PID%cpu%MEM VSZ RSS TTY STAT START time Commandroot1 0.0 0.1 1740 540? S Jul250: oninit [3]root2 0.0 0.0 0 0? SN Jul250:xx[ksoftirqd/0]root3 0.0 0.0 0 0? s< Jul250:xx[events/0]..... Middle omitted ... root5881 0.0 0.3 5212 1204pts/0STen: A 0:xx suRoot5882 0.0 0.3 5396 1524pts/0STen: A 0:xxBashroot6142 0.0 0.2 4488 916pts/0r+ One: $ 0:xx PSaux# User: Does the process belong to that user account? # PID: The number of the process. # %CPU: The percentage of CPU resources that the process uses;%MEM: The percentage of physical memory occupied by the process; # VSZ: The amount of virtual memory (Kbytes) # RSS that the process consumes (Kbytes) # TTY: The process is at that end Terminal machine, if not related to the terminal, the display?, in addition, TTY1-TTY6 is the login program on this machine, if the pts/0and so on, it is the program that is connected to the host by the network. # STAT: The current state of the program, the main state is: # R: The program is currently operating, or can be operated; # S: The program is currently sleeping (can be said to be idle!) ), but can be awakened by certain signals (signal). # T: The program is currently being detected or is stopped; # Z: The program should have been terminated, but its parent program could not properly terminate him, causing the zombie (zombie) program Status # Start: The time the process was triggered to start; # times: The process actually uses The time the CPU is operating. # command: What is the actual instruction of the program? 

  Example 3: The display of example one is only the current user, and the following shows all the user's programs

[Email protected] ~]#PS-LAF S UID PID PPID C PRI NI ADDR SZ wchan TTY time CMD4S0 1 0 0  the 0-435- ?xx:xx: onInit1S0 2 1 0 94  +-0Ksofti?xx:xx:xxksoftirqd/01S0 3 1 0  --5-0Worker?xx:xx:xxevents/0..... The following omit .....

  Example 4: listing programs showing similar program trees

[Email protected] ~]#PS-axjfppid PID pgid SID TTY tpgid STAT UID time COMMAND0 1 0 0? -1S0 0: oninit [3]1 2 0 0? -1SN0 0:xx[ksoftirqd/0]..... The middle is omitted .....1 5281 5281 5281? -1Ss0 0:xx/usr/sbin/sshd5281 5651 5651 5651? -1Ss0 0:xx\_ Sshd:dmtsai [Priv]5651 5653 5651 5651? -1S - 0:xx\_ sshd: [Email protected]/05653 5654 5654 5654pts/0 6151Ss - 0:xx\_ -Bash5654 5881 5881 5654pts/0 6151S0 0:xx\_su5881 5882 5882 5654pts/0 6151S0 0:xx\_ Bash5882 6151 6151 5654pts/0 6151r+0 0:xx\_PS-axjf

  Example 5: find PID related to cron and syslog services

[Email protected] ~]#PSAux |Egrep '(Cron|syslog)'Root1539 0.0 0.1 1616 616? Ss Jul250:GenevaSyslogd-m0Root1676 0.0 0.2 4544 1128? Ss Jul250:xxCrondroot6157 0.0 0.1 3764 664pts/0r+ A:Ten 0:xx Egrep(Cron|syslog)

In the case of presets, PS only lists the PID associated with the current bash shell, so when I use ps-l, there are only three PID (example one).

Resources

[1] http://blog.csdn.net/k122769836/article/details/8625155

[2] Http://www.cnblogs.com/allen8807/archive/2010/11/10/1873843.html

"Linux" PS command

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.