Linux Process Management (version 2)-process management commands

Source: Internet
Author: User

Linux Process Management (version 2)-process management commands
Process Management commands

1. View user information

1. Meaning of w display information

TTY: indicates the user logon method. ttyN: Indicates logging on from a local terminal; pts/N indicates logging on from a remote terminal.

JCPU: distinguished by Terminal code. The CPU time consumed during execution of all related processes on the terminal is displayed here

PCPU: CPU execution time

WHAT: The operation that the user is performing

Load average: displays the average load of the system in the past 1, 5, and 15 minutes, respectively. Generally, under 0.8, we think the system load is light]

FROM: displays where the user logs on to the system. ": 0" indicates that the user logs on from x Window when the user logs on to the system.

IDLE: the time when the user is IDLE. This is a timer. Once you perform any operation, the timer will be reset.

2. View individual user information: w User Name

Ii. view system process ps

1. Common options

A: displays the processes of all users.

U: displays the user name and start time

X: displays the processes without control terminals.

E: displays all processes, including those without control terminals.

L: long format display

W: Wide Row display. You can use multiple w for wide display.

2. Definitions of common ps output information

PID: process ID

PPID: process ID of the parent process

TTY: the terminal started by the process.

STAT/S: Current Process status

# S sleep state, D Non-interrupted sleep state, R running state, Z dead state, T stopped

NI (nice): Process Priority

TIME: The total CPU usage of a process since it was started.

COMMAND/CMD: COMMAND name of the process

USER: USER Name

% CPU: Percentage of CPU usage time and total time

% MEM: Percentage of occupied memory and total system memory

3. [application example]

Ps: view your own processes

Ps-u or-l: view detailed information of the affiliated Processes

Ps-le or-aux displays detailed information about all processes executed by users, but-aux displays some very intuitive displays, such as % MEM, % CPU

[Best Practice: ps-le | grep httpd. You can also view/etc/rc. d/init. d/httpd status or service httpd status by starting the script]

Ps-aux -- sort time/pid/uid # process can be sorted by process execution time, PID, UID, etc.

Ps-uU sam or ps-aux | grep sam # view processes executed by a specified user in the system

Ps-le | grep init # view the information of a specified process

 

[Pstree can also be used to view the process information in a tree in the system]

3. kill the process

1. Why should we kill the process?

This process occupies too much CPU time

This process shrinks to one terminal, making other foreground processes unable to run.

The running time is too long, but it does not have the expected effect.

Excessive output to screen or disk files is generated

Unable to exit normally

2.

[Use process number as a parameter to close the process]

Kill process number: kill Process

[If you want to shut down a group of processes because they have a common parent process, close the parent process]

Kill-9 process no.: Force disable

Kill-1 process no.: restart the process

[Kill-l will list all signals]

Xkill: Close the graphics program

Killall [process name]: Shut down all processes

For example, killall httpd # Shut down the Apache server, killall shut down all processes with the same name as httpd

Certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[Service name as a parameter]

Pgrep service name: Find the service process ID PID

For example, pgrep httpd can retrieve the PID of all httpd processes.

E. g kill-1 'pgrep httpd'

Pkill process name: Shut down the process

Appendix-The/proc directory is saved in the memory, and the system details and process information are saved. The number indicates the PID of the currently running process.

4. Specify priority

[* Priority value range: (-20, 19) * The default start priority is 0. The smaller the priority value, the greater the priority]

1. nice specifies the priority of the program running

Nice-n command

For example, nice-5 myprogrem

Nice -- 5/etc/rc. d/init. d/httpd start # priority:-5

2. renice changes the priority of a running process.

Format: renice n pid [Note: there is no "-" here]

For example, renice-30 777

5. The nohup command causes the process to continue executing after the user logs out.

The nohup command saves the executed data and error information to the file nohup. out by default.

Format: nohup program &

For example: nohup find/-name init *>/root/find.init.info &

6. Process suspension and recovery

1. Process suspension (suspension/suspension) and termination

Hold Ctrl + Z

Terminate Ctrl + C # [1] + Stopped

2. View jobs of suspended and running processes in the background.

3. process recovery

Resume to the foreground and continue executing the fg [number displayed by jobs], for example, fg 1.

Resume to the background and continue to execute bg [jobs view number] For example: bg 1

VII. top Command

Purpose: display the Process status and process control. By default, the process is automatically refreshed every 3.0 seconds (dynamically displayed)

Option: [used in top software running]:

D: Specifies the interval of refreshing.

C: display the entire command line, not just the command name

U: View processes of a specified user

K: Terminate the process in progress.

H or? : Get help

R: reset the process priority.

S: Change the Refresh Interval

W: Write the current settings ~ /. Toprc File

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.