Linux disk and file system (5) ------ process

process

A process is an executing program or command. Each process is a running entity, has its own address space, and occupies certain system resources.

Process management application scenarios
1. Determine the health status of the server
2. View all processes in the system
3. Kill the process


difference between process and program
1. A program is a static concept, which itself is stored for a long time as a software resource; while a process is the execution process of a program, it is a dynamic concept, has a certain life period, and is dynamically generated and destroyed.
2. There is no one-to-one correspondence between programs and processes. A program can be shared by multiple processes; on the other hand, a process can execute several programs sequentially in the activity


Process classification: system process user process interactive process batch process daemon process

Process status:



View all processes in the system
# ps aux use BSD OS format
# ps -le Use the standard Linux command format




USER: which user the process was created by
PID: The ID number of the process
%CPU: The percentage of CPU resources occupied by the process, the higher the occupancy, the more resources the process consumes
%MEM: The percentage of physical memory occupied by the process. The higher the occupancy, the more resources the process consumes
VSZ: The size of the virtual memory occupied by the process, in KB
RSS: The size of the actual physical memory occupied
TTY: In which terminal the process is running. Among them, tty1-tty7 represents the local console terminal, tty1-tty6 is the local character interface terminal, and tty7 is the graphic terminal. pts/0-255 stands for virtual terminal.
STAT: Process status. Common states are: R: running, S: sleep, T: stopped state, s: parent process, +: in the background, "Z" is used for zombie processes, "<" is used for high-priority processes, and "N" is used. ” indicates a lower priority process
START: the start time of the process
TIME: This process occupies the computing time of the CPU, note that it is not the system time
COMMAND: The name of the command that spawned this process


View system health status

top tool
The top command is an indispensable tool for monitoring system processes. Compared with the ps command, the top command dynamically displays the process status in real time, while ps can only display the information of the process at a certain moment. At the same time, the top command provides an interactive interface, users can You can customize your own output according to your needs, and understand the real-time status of the process more clearly




The first line: task queue information  
18:03:32 The current time of the system up 1:30 The running time of the system 1 user Two users are currently logged in  
load average: 0.00,0.00,0.00 The average load of the system in the previous 1 minute, 5 minutes, and 15 minutes. It is generally considered that when it is less than 1, the load is small. If greater than 1, the system has been overloaded

The second line: process information   
Tasks: 124 total total number of processes in the system 1 running number of processes running 123 sleeping processes 0 stopped processes being stopped 
0 zombie : Zombie process. If not 0, you need to manually check for zombie processes

The third line: CPU information
Cpu(s): 0.0%us The percentage of CPU occupied by user mode 0.0%sy The percentage of CPU occupied by system mode 0.0%ni The percentage of CPU occupied by user processes whose priority has been changed 99.7%id The percentage of CPU occupied by idle CPU 0.0%wa Waiting for input The percentage of CPU occupied by the output process 0.0%hi The percentage of CPU occupied by the hard interrupt request service
0.3%si The percentage of CPU occupied by the soft interrupt request service 0.0%st The percentage of virtual time (when there is a virtual machine, the percentage of time that the virtual CPU waits for the actual CPU)

Fourth line: physical memory information

Mem: 1012352k total total physical memory 334196k used used physical memory 678156k free free physical memory  
35920k buffers as the amount of buffer memory

Fifth line: swap partition (swap) information
Swap: 2031608k total, the size of the swap partition (virtual memory) 0k used the size of the interactive partition used 2031608k free the size of the interactive partition with the free swap partition 104680k cached as the cache


View progress

pidof – used to find the PID of a running program.
pstree view the process tree -p show the PID of the process -u show the user of the process


process priority
The priority range provided by Linux is -20 to 19. When we start a process, the default priority is 0, and the priority of -20 is the largest, or the highest. Of course, we can write -30 when setting, but the system defaults to -20.

nice command
Specifies the running priority of the program
Format: nice -n command
For example: nice -n 5 command
renice command
Change the priority of a running process
Format: renice n pid
Example: renice -5 777

[root@localhost ~]# kill -1 22354
# restart process
[root@localhost ~]# kill -9 22368
#Force kill process

[root@localhost~]# killall[options][signal] process name
#kill process by process name
Options:
-i: interactive, ask if you want to kill a process
-I: ignore case of process names

[root@localhost~]# pkill [options] [signal] process name
# Terminate process by process name
Options:
-t terminal number: kick out users by terminal number
pkill is equivalent to pgrep+kill

[root@localhost~]# w
#Use the w command to query the logged in users of the machine
[root@localhost~]# pkill -t -9 pts/1
#Force kill the process logged in from the pts/1 virtual terminal






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325818803&siteId=291194637