Linux process Management (i)

Source: Internet
Author: User
Tags cpu usage

Concept of Process Management

1. The program is static, itself as a long-term software resources, and the process is dynamic, there is a certain life cycle, is the dynamic generation and extinction, the process of each execution of a time slice length in the kernel, when the time slice end process will let out the kernel to the next waiting to run the process , the process will keep its information in the memory structure, so that when the process is executed again, the information saved by the memory structure can reach the state of the last execution;

2. Procedures and processes do not have one by one correspondence, the process in the state of running back to use the program;

3. The process is a parent-child relationship; The child process is created by the parental process, and the data, stack segments, and process environment of the parent process are placed in the child process through the fork () system call, and when the child process finishes its work, the child process is recycled by its parent process, and the copy of the parent process into the child process is Enabled only when a child process is called;

In the CentOS environment, the kernel performs an init () process to initialize the system after it is enabled.

CentOS5 and Previous versions: SysV Init,classic Init

The init () process is executed by Init to create the child process to execute the script to create the child process, the CentOS5 is executed serially, one by one to execute these scripts, so the speed will be very slow;

Centos6:upstart

The init () process is executed by Init to create a subprocess, which, unlike CentOS5, is executed in parallel, creating multiple processes at the same time, which, if it has more than one CPU, is more visible and runs faster;

Centos7:systemd

It is possible to start the whole operating system independently of itself, that is, to start a systemd process, you can start other service processes, which are the processes we currently need, and when we need more, we will enable them. So the CentOS7 will run faster than before;

Foreground process: In the foreground input command, create the corresponding sub-process, in the time of the command run, the foreground can not run other processes;

Background process: In the foreground input command, create the corresponding sub-process, command run into the background execution, do not occupy the foreground;

Daemon: is enabled during the system boot process, regardless of any terminal;

User process: The user logs on to the system before it is enabled, through the terminal start process;

Process priority: The execution of a process is based on its priority to determine which execution, after that, and the priority level of the process from 0 to 139

0 to 99 is the system priority, the higher the value the higher the priority, the 100 to 139 is the static priority, the lower the value the higher the priority;

Nice value: 20 to 19

0 indicates that 120,-20 in the priority level indicates that 100,19 represents 139; Only the administrator can use a negative integer to increase the priority of the process, the user can only use positive integers to reduce the priority of the process;

Nice-n Priority Process Name

Run the process and specify the priority level;

Renice-n Priority Process Name

For processes that are already running, modify their priority levels;


Process-related commands

Pstree: Show Process Tree

PS: Display process-related information, such as the effective user, PID, CPU and memory consumption percentage, etc.;

PS has two types of options

BSD Style:

A: terminal-related processes;

X: Processes unrelated to the terminal;

U: Displays the user account name of the initiating process;

Cases

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/9C/EC/wKiom1l3-l2iYTWfAABTEZ9VEiM040.jpg-wh_500x0-wm_ 3-wmp_4-s_3507728917.jpg "title=" qq20170726101118.jpg "alt=" Wkiom1l3-l2iytwfaabtez9veim040.jpg-wh_50 "/>

USER: The owner of the process;

PID: Process identifier;

%CPU: The percentage of CPU that the process consumes;

%MEM: The percentage of memory that the process consumes;

VSZ: virtual memory set;

Rsz: Resident memory set;

STAT: Process Status

R: Running;

S: interruptible sleep state;

D: Non-disruptive sleep status;

T: Tracked/stopped;

Z: Zombie State;

+: foreground process;

<: high-priority processes;

N: low-priority process;

Time: CPU usage accumulated by the process;


UNIX style:

-E: All processes;

-F: Displays process information in full format;

-H: Show parent-child relationship in hierarchical structure;

Cases

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/9C/EC/wKioL1l3_DnQQccnAABRZrgnL9A154.jpg-wh_500x0-wm_ 3-wmp_4-s_3204904030.jpg "title=" qq20170726101921.jpg "alt=" Wkiol1l3_dnqqccnaabrzrgnl9a154.jpg-wh_50 "/>

PPID: Parent process pid;

SZ: virtual memory set;

RSS: Resident memory set;

PSR: Indicates which CPU core the process is running on;

C: Indicates the percentage of CPU time consumed by the process;

Pgrep: Search related processes;

-U UID: a process that searches for the user as a valid user based on the UID of the user;

-U uid: According to the user UID search for the user as a real user process;

-L Pattern: Search process name, based on some process name related information;

Cases

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/9C/EC/wKioL1l3_ePT2lBBAAAUgu9U6Wk728.jpg-wh_500x0-wm_ 3-wmp_4-s_2768038630.jpg "title=" qq20170726102631.jpg "alt=" Wkiol1l3_ept2lbbaaaugu9u6wk728.jpg-wh_50 "/>

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/9C/EC/wKioL1l3_g6j1NsNAAAa69SqPAs289.jpg-wh_500x0-wm_ 3-wmp_4-s_2050983471.jpg "title=" qq20170726102714.jpg "alt=" Wkiol1l3_g6j1nsnaaaa69sqpas289.jpg-wh_50 "/>

Pidof: Displays the process ID corresponding to the process name;

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/9C/EC/wKiom1l3_jXCyXMwAAAMlfHo1_I608.jpg-wh_500x0-wm_ 3-wmp_4-s_772241147.jpg "title=" qq20170726102754.jpg "alt=" Wkiom1l3_jxcyxmwaaamlfho1_i608.jpg-wh_50 "/>

Top: Display the relevant information of the process, more comprehensive;

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/9C/EC/wKiom1l4AKLwLzBvAAC_iPxIouk683.jpg-wh_500x0-wm_ 3-wmp_4-s_2632251747.jpg "title=" qq20170726103813.jpg "alt=" Wkiom1l4aklwlzbvaac_ipxiouk683.jpg-wh_50 "/>

First line:

Current system time

System Run time

Current number of System user logins

Average number of process waits in 1 minutes, 5 minutes, 15 minutes

Second line

Total number of processes

Number of process runs

Number of Process sleeps

Number of process waits

Process Zombie Number


Third line

Percentage of CPU occupied

US: Percentage of CPU consumed by the user process;

SY: The percentage of CPU that the kernel-level process consumes;

NI: Use the nice value to adjust the percentage of CPU that is occupied by the process priority;

ID:CPU idle time percentage;

WA: Percentage of CPU waiting for IO to complete;

Hi: The percentage of CPU that the hardware interrupt consumes;

Si: Percentage of CPU occupied by software terminal;

ST: the percentage of CPU time stolen by the virtualization program, etc.;

Line Four

Memory-related information


Line Five

Display the swap space usage in kilobytes:


Line Six

Process-related information


The top command is a foreground process with interactive commands

1: Show the usage of different CPU cores;

P: The percentage of CPU consumption is sorted and displayed;

M: Sort display of memory consumption percentage;

T: Sort According to the accumulated CPU time;

Q: Exit the top command;


Vmstat: actual memory statistics;

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/9C/ED/wKioL1l4BL-x59B2AAAw4gU0bjs098.jpg-wh_500x0-wm_ 3-wmp_4-s_3855752839.jpg "title=" qq20170726105543.jpg "alt=" Wkiol1l4bl-x59b2aaaw4gu0bjs098.jpg-wh_50 "/>

Procs

R: Number of processes that are running;

B: number of blocked processes;

Memory

SWPD: The amount of memory being used;

Free: The amount of idle memory;

Buff: The number of memory in the data buffer;

Cache: The number of memory in the data buffer;

The amount of memory in the buff and cache is available;

Swap

Si: Number of processes entering the swap space;

So: the number of processes going out to swap space;

Io

BI: The amount of block data entered into memory;

Bo: The number of memory data entering the block data;

System

In: The number of hardware interrupts and software interrupts;

CS: Context switch;

Cpu

US: Percentage of CPU consumed by the user process;

SY: The percentage of CPU that the kernel-level process consumes;

ID: Percentage of idle CPU;

WA: Percent of CPU waiting for IO to complete;

ST: the percentage of CPU time stolen by the virtualization program, etc.;


Process Management Commands:

Kill: Close Process

Kill [Signal] PID

Signal

1) SIGHUP: No need to close the corresponding process and let it re-read its own configuration file;

2) SIGINT: Terminate the running foreground process;

9) SIGKILL: No omen of termination of the running process, brutality;

SIGTERM: The default signal to terminate the running process;

Sigcont: Let the process continue to run in the background;

SIGSTOP: Let the process into the background and stop running;

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/9C/F0/wKiom1l4EVvhm2DqAAAyRlAucg0984.jpg-wh_500x0-wm_ 3-wmp_4-s_1995209861.jpg "title=" qq20170726114932.jpg "alt=" Wkiom1l4evvhm2dqaaayrlaucg0984.jpg-wh_50 "/>

Killall: Close all processes with the same name;

Killall Process Name


Jobs: view background processes;

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/9C/F1/wKiom1l4KEKQdwjBAAAN_nYFqhA460.jpg-wh_500x0-wm_ 3-wmp_4-s_1288560701.jpg "title=" qq20170726132719.jpg "alt=" Wkiom1l4kekqdwjbaaan_nyfqha460.jpg-wh_50 "/>

Background process In addition to the beginning of the process running in the background, you can also transfer the foreground process to the background to run;

①ctrl+z: Press the button after the foreground process, make it into the background;

② command &: Add a "&" to run the command directly into the background, such a process is a terminal-related process, if the terminal is closed, such processes will also be terminated;

③nohup command &: To enable it to be launched and into the background, such a process is a terminal-independent process;


BG: Background jobs run in the background;

BG ID

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/9C/F2/wKioL1l4KuKiWfreAAAfS7oVTNw494.jpg-wh_500x0-wm_ 3-wmp_4-s_4201224088.jpg "title=" qq20170726133833.jpg "alt=" Wkiol1l4kukiwfreaaafs7ovtnw494.jpg-wh_50 "/>

FG: Put the background job into the foreground to run;

FG ID














Linux process Management (i)

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.