A Process Management
Process Type:
Daemon process, foreground process.
Process Status:
Operating Status: Running
Readiness Status: Ready
Sleep state:
Final Break: Interruptabe
Non-disruptive: Uninterruptabe
Stop state: Pauses with memory, but is not scheduled unless manually started
Zombie Status: End process, child process does not close before parent process ends
LRU: Least Recently used algorithm:
(1) For example, there are 1 2 3 44 processes first the program has recently called a 4 process
(2) program sequencing changed to 4 1 2 3 at this point three rows will be deleted at the end 4 1 2
(3) in the next if 2 is not scheduled will be deleted, but if 2 is dispatched once
(4) Sort by 2 4 1 Subsequent 1 processes are deleted.
PS shows a description of the current process status:
BSD mode
A foreground process for all users running on all terminals
x all processes running by the current user (including foreground process and background daemon)
Ax all users running all processes
Aux all users run all processes, the result shows the user name
F Show Parent-child process relationships
-C filtering with the process name
AXO Coordination
o Custom Output columns
%cpu
%mem
Pid
Uid
Gid
Cmd
Comm
TTY displays the terminal name, such as, to indicate the daemon background process
Initiator of the Ruser command
The true executor of the Euser command
State
R:running
S:interruptable sleeping
D:uninterruptable sleeping
t:stopped
Z:zombie
+: Foreground process
L: Multithreaded Process
L: Memory Paging with lock
N: Low-priority process
<: high-priority processes
S:session leader, session (child process) initiator
For example: [email protected] rc5.d]# PS Axo%cpu,%mem,pid,comm
[Email protected] rc5.d]# PS Axo%cpu,%mem,pid,comm k-%cpu
[[email protected] calhost rc5.d]# PS Axo%cpu,%mem,pid,euser,ruser,comm k-%cpu |grep passwd where Euser is the initiator of the command's performer Ruser command
K Sort or--sort
Echo $$ shows the process number of the currently running process
VSZ: Virtual memory set, linear memory represents operating system committed memory set
RSS: Resident memory sets actually allocating memory
Unix mode:
-E Show All processes
-F Display Full format
-ef Show all processes in full format
-ef Show all processes in a more complete format
-EFH Show Parent-child process relationships
-eo custom display results, as follows
Ps-eo%cpu,%mem,pid,nice,pri,stat,comm
Two. Process Search Tool:
Pgrep:
-u:uid/username search based on the user name of the executing program
-L: Show the process name in the results shown for example: [[email protected] ~]# Pgrep-lu root
-T terminal name: Specify terminal-related processes
-L: Show process name
-A: Displays the process name in full format
-P PID: Shows the child process of the development process
PIDOF process name Query PID for the process name for example: Pidof Ping can also help kill processes with this command: [[email protected] ~]# kill-9 $ (pidof ping)
Uptime (CPU Information):
[Email protected] ~]# uptime
16:59:03 up 5:49, 3 users, load average:0.07 (load in one minute), 0.04 (five min. load), 0.05 (load within 15 minutes)
Typically, a day's load of not more than 3 indicates a good CPU performance
Three Process priority
Static priority: 100-139
When the process is started by default, the nice value is 0, and the priority is 120. Only the root user can reduce the nice value.
Nice command:
Before we execute the nice command, we need to find out the process number: Ps-ef |grep Ping
Then change the nice value: renice-n-20 38650
Nice value:
-20~19
The smaller the number, the higher the priority
Renice-n # ( -20~19) PID (Process if active with this command)
Nice-n # ( -20~19)-# command
View mode
PS Axo Ni[ce]
Four. Linux Process view Management tools:
Example: Vmstat 2 5: Refresh every two seconds refresh five stops
Vmstat the options in the command mean:
Vmstat [Operation][delay [Count]]
Procs
R; Number of processes waiting to run
B: Block queue Length, which is the number of processes in the non-disruptive sleep state
Memory
SWPD: Total amount of virtual memory used
Free: The amount of material memory is idle until it is insufficient to use virtual memory
Buff: The total amount of memory used for Baffer
Cache: The total amount of memory used for the cache
Swap
SI: Data rate for data entry into swap (KB/S)
So: Data rate from swap
Io
BI: The rate at which data is read from the block device to the system (KB/S)
Bo: The rate at which data is saved to a block device
System
In:interrupts, Interrupt rate
Cs:context switch, process switching rate
Cpu:
US user space occupies proportion
Sy core space occupies CPU ratio
ID Idle ratio
The percentage of time that WA waits for I/O to complete
ST: Percentage of time stolen by virtualization
Vmstat Command options:
-S: Shows the statistics of memory
Iostat
Pmap PID
Pmap-x PID
Ls-l/proc/40052/fd |wc-l
Determine if there is a memory leak by looking at whether the number of process file descriptors is growing
Glances command:
Run the Glance command in C/s mode
Service mode:
Glances-s-B IP Address: Listen to an address on this machine
Customer mode
GLANCES-C server IP address to connect: unsafe recommended Use-p or a different port.
Long-use options
-B: Displays the network card data rate in Byte, or byte;
-D: Turn off the disk I/O module
-f/path/to/somefile: Setting the output file location
-O {html| CSV}: Output format
-M: Disable Mount Module
-N: Disable network module
-T #: Delay time interval
-1 (digital): the relevant data for each CPU is displayed separately;
Dstat command:
Dstat [-AVF] [Options ...] [Delay[count]]
Dstat-d TOTAL,SDA But all look at SDA information
Common options:
-C: Display CPU-related information
-C #,#,...,total
-D: Show disk-related information
-D Total,sda,sdb,...
-G: Show page-related data
-I: Show broken statistics
-l:1,5,15, data information
-M: Display Memory related statistics
-N: Display Network related statistics
-P: Show statistics for new processes
-R:I/O Request related statistics
-S: Swapping memory-related statistics
--tcp
--udp
--unix
--raw
--socket: Equivalent to--tcp,--UDP,--raw
--IPC: Related information statistics for interprocess communication
--TOP-CPU: View the process that consumes the most CPU
--top-io: Show most io-intensive processes
--top-mem: Shows the most memory-intensive processes;
--top-lantency: Show the process with the most delay
Kill command:
-0 Nothing, can be used to simply determine whether the process is running.
-1-hup: Forcing the process to reread the configuration file
-2-int: Aborts a running process, equivalent to CTRL + C
-3-quit: Equivalent to Ctrl+\
-9-kill: Forces a running process to be killed
-15-term: Terminates a running process (default) \
Killall Process Name
Pkill
-u user name kills all processes running by the specified user
Pkill-t PTS/1 kills all processes running on the specified terminal
V: Job control for Linux:
CTRL + Z will run the process in the foreground pause or kill-19 PID
BG will suspend the process on the current terminal, put it in the background to continue running or kill-18 PID
FG will be paused on the current terminal or run in the background on the current terminal and put into the foreground to continue running
Jobs: View all jobs on the current terminal
Make the process no longer dependent on the terminal to run in the background
Nohup command &>/dev/null
Screen Command
(command&)
Run multiple commands in parallel
Three different methods
Vim all.sh
sh1&
sh2&
shn&
(sh1&);(sh2&)
{SH1&SH2&SH3}
Introduction to Process Management commands