Process Management
Process Processes
A process opened by an application
PIDProcess ID
Type:
User space Process
Kernel space Process
To view the status of a process statically
# PS
[[Email protected] ~]# PS>>>> View the process of this terminal
PID TTY Time CMD
4206 pts/0 00:00:00 Bash
4378 pts/0 00:00:00 PS
How to use options:
BSD style: Option without horizontal- PS aux
SYSV style: Option required with horizontal line -ps-elf
BSD Style:
A shows the process associated with the terminal
U Show the user who started the process
x Show processes unrelated to the terminal
[Email protected] ~]# PS a
PID TTY STAT Time COMMAND
3303 Tty2 ss+ 0:00/sbin/mingetty/dev/tty2
3305 Tty3 ss+ 0:00/sbin/mingetty/dev/tty3
[[Email protected] ~]# PS u
USER PID%cpu%MEM VSZ RSS TTY STAT START time COMMAND
Root 3303 0.0 0.0 4064 544 tty2 ss+ 09:06 0:00/sbin/mingetty/dev/tty2
Root 3305 0.0 0.0 4064 544 tty3 ss+ 09:06 0:00/sbin/mingetty/dev/tty3
User running the process
Percentage of CPU consumed by the%CPU process
Percentage of MEM defeated by the%MEM process
VSZ Virtual memory set, process-exclusive memory + share exists
The unique memory of the RSS process
Status of the STAT process
D: Non-disruptive sleep (wait for disk IO to complete)
S: interruptible sleep (no need to wait for disk IO to complete)
R: Run or ready
T: Stop
Z: Zombie Zombie
<: high-priority process
will be executed by CPU first
Will get more CPU execution time
N: Low-priority process
+: Processes in the foreground process group
L: Multithreaded process (thread)
S: Session process first process, one connection parent process
[[Email protected] ~]# PS aux | Less
USER PID%cpu%MEM VSZ RSS TTY STAT START time COMMAND
Root 1 0.0 0.0 19364 1536? Ss 09:05 0:00/sbin/init
Root 2 0.0 0.0 0 0? S 09:05 0:00 [Kthreadd]
Root 3 0.0 0.0 0 0? S 09:05 0:00 [migration/0]
Root 4 0.0 0.0 0 0? S 09:05 0:00 [ksoftirqd/0]
With square brackets for system (Linux kernel boot)
Incompetence Allende brackets (user process)
[[Email protected] ~]# PS aux | grep vim
Root 5550 0.2 0.0 143972 3760 pts/2 s+ 10:25 0:00 vim/etc/fstab
Root 5564 0.0 0.0 103260 860 pts/0 s+ 10:25 0:00 grep--color vim
SYSV style options:
- e Show All Processes
- L Detailed information
- F display in long format (more field content)
[Email protected] ~]# Ps-elf | Less
F S UID PID PPID C PRI NI ADDR SZ wchan stime TTY time CMD
4 S root 1 0 0 0-4841 poll_s 09:05? 00:00:00/sbin/init
1 S root 2 0 0 0-0 kthrea 09:05? 00:00:00 [Kthreadd]
1 S Root 3 2 0-40--0 migrat 09:05? 00:00:00 [migration/0]
1 S Root 4 2 0 0-0 ksofti 09:05? 00:00:00 [ksoftirqd/0]
1 S Root 5 2 0-40--0 cpu_st 09:05? 00:00:00 [stopper/0]
5 S Root 6 2 0-40--0 watchd 09:05? 00:00:00 [watchdog/0]
1 S Root 7 2 0-40--0 migrat 09:05? 00:00:00 [MIGRATION/1]
Process priority:
0----139
The smaller the data, the higher the first level
High-priority processes:
Get CPU More Execution time
will be executed by CPU first
Nice value:
New priority = Old Priority +nice value
-20----19
Ordinary users can only adjust the nice value, that is, to reduce the process priority
Root user is free to adjust the nice value
Show Process Tree
[Email protected] ~]# Pstree
Init─┬─abrtd
├─acpid
├─atd
├─AUDITD───{AUDITD}
├─automount───4*[{automount}]
├─bonobo-activati───{bonobo-activat}
├─certmonger
├─clock-applet
├─CONSOLE-KIT-DAE───63*[{CONSOLE-KIT-DA}]
├─crond
Show Process PID
[Email protected] ~]# pidof vim
5696
[Email protected] ~]#
Dynamically view the status of a process
# Top
top-10:53:46 up 1:48, 3 users, Load average:0.12, 0.19, 0.16
tasks:239 Total, 2 running, 237 sleeping, 0 stopped, 0 zombie
Cpu (s): 7.6%us, 1.6%sy, 0.0%ni, 90.6%id, 0.0%wa, 0.0%hi, 0.2%si, 0.0%st
mem:16084568k Total, 2529012k used, 13555556k free, 70044k buffers
swap:8388604k Total, 0k used, 8388604k free, 626388k cached
7.6%us CPU consumed by user processes
1.6%sy CPU consumed by the system process
0.0%ni CPU adjusted by priority process
90.6%idCPU Idle
0.0%wa CPU consumed by the process waiting for disk IO
CPU (s): Show all CPU averages, press 1 to show the usage of each CPU
Top Interactive Instructions:
M: Sort by memory usage
P: Sort by CPU usage
T: Sort by run time
L: Whether to display top line 1th information
M: Whether memory usage information is displayed
T: whether to display CPU and task information
C: Whether the full command line is displayed
Q: Exit Top
Displays CPU usage at the current moment
[Email protected] ~]# uptime
11:00:25 up 1:54, 3 users, load average:0.39, 0.26, 0.19
Top options:
-D 1: Specify how often top information is refreshed
-B: Show process information in batch mode
-N 2: Display of two batches of information
# top-d 1-b-N 2
To view server performance:
1, PS, top
2, Df-ht
3, Free-m
[Email protected] ~]# uptime
11:39:00 up 3:24, 4 users, Load average:0.00, 0.01, 0.05
# mpstat View CPU
# Vmstat View Memory
# iostat View disk
[Email protected] ~]# Rpm-qf/usr/bin/iostat
Sysstat-10.1.5-7.el7.x86_64
[Email protected] ~]#
Process Control
Signal: Signal
View all signals
[Email protected] ~]# kill-l
1) SIGHUP 2) SIGINT 3) sigquit 4) Sigill 5) SIGTRAP
6) SIGABRT 7) Sigbus 8) SIGFPE 9) SIGKILL) SIGUSR1
One) (SIGSEGV) (SIGUSR2) sigpipe) sigalrm) SIGTERM
Sigstkflt) (SIGCHLD) sigcontSIGSTOP) SIGTSTP
(Sigttin) Sigttou() Sigurg) sigxcpu) Sigxfsz
(Sigvtalrm) sigprof) sigwinchSIGIO) SIGPWR
Sigsys) (sigrtmin) sigrtmin+1) sigrtmin+2Notoginseng) sigrtmin+3
Sigrtmin+4) sigrtmin+5(sigrtmin+6) sigrtmin+7) sigrtmin+8
Sigrtmin+9) (sigrtmin+10) sigrtmin+11() sigrtmin+12) sigrtmin+13
(sigrtmin+14) sigrtmin+15() SIGRTMAX-14) SIGRTMAX-13) SIGRTMAX-12
SIGRTMAX-11) SIGRTMAX-10SIGRTMAX-9) SIGRTMAX-857) SIGRTMAX-7
(SIGRTMAX-6) (SIGRTMAX-5) SIGRTMAX-4) SIGRTMAX-3) SIGRTMAX-2
SIGRTMAX-1) Sigrtmax
Common signals:
1 SIGHUP: Let a process not restart, you can reread its configuration file, and let the new configuration take effect
2 SIGINT: Hardware interrupt signal, CTRL + C
9 SIGKILL: Kill a process
SIGTERM: Terminating a process
How do I call a signal?
Signal Number: kill-9 <PID>
Signal Name: Kill-sigkill <PID>
Signal name shorthand: Kill-kill <PID>
# Kill <PID>
# Killall <PROCESS_NAME>
Control how the process runs (foreground/background)
Front desk: Occupy command prompt
1) control commands run in the background
# Command &
[email protected] ~]# Firefox &
2) Viewing applications in the background
[Email protected] ~]# jobs-l
[1]+ 12066 Running Firefox &
3) put the running instructions in the background and pause the operation
CTRL + Z
4) Back up the backstage program to the foreground to continue running
# FG < background task number >
[[email protected] ~]# FG 1
This article is from the "lyw666" blog, make sure to keep this source http://lyw666.blog.51cto.com/12823216/1957484
Linux Process Management