Let's take a look at the management of RHEL6 system processes. We know that the program itself will contain its own management programs, such as shutting down and restarting. In addition to the built-in ones, we can also send signals to tell the program what to do. This is what we will introduce below. Let's take a look at several common signals [root @ yufei ~] # Kill-l1) SIGHUP2) SIGINT3) SIGQUIT4) SIGILL &
Let's take a look at the RHEL6 system process management.
As we know, General programs will contain their own management programs, such as shutting down and restarting. In addition to the built-in ones, we can also send signals to tell the program what to do. This is what we will introduce below.
Let's take a look at some common signals.
[Root @ yufei ~] # Kill-l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN + 1 36) SIGRTMIN + 2 37) SIGRTMIN + 3
38) SIGRTMIN + 4 39) SIGRTMIN + 5 40) SIGRTMIN + 6 41) SIGRTMIN + 7 42) SIGRTMIN + 8
43) SIGRTMIN + 9 44) SIGRTMIN + 10 45) SIGRTMIN + 11 46) SIGRTMIN + 12 47) SIGRTMIN + 13
(48) SIGRTMIN + 14 49) SIGRTMIN + 15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
(53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8
(58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62)
63) SIGRTMAX-1 64) SIGRTMAX system has so many signals, we don't care about him, as long as you come to understand a few common OK, if you want to carefully study friends, go to the Internet to find the corresponding content or view the help of signal (if man 7 signal does not have this command, install the man-pages package ).
1 SIGHUP start the terminated program, which allows the PID to re-read its configuration file, similar to restarting
2 SIGINT: press ctrl + c on the keyboard to interrupt a program.
9 SIGKILL indicates that a program is forced to stop. If half of the program is executed, the unfinished part may be generated by "half-product", similar to vim, which will be retained by. filename. swp.
15 SIGTERM terminate the program with a normal ending program. It is a normal termination, so the subsequent action will be completed. However, if the program has encountered a problem, it is impossible to use the normal method to terminate, it is useless to enter this signal.
17 SIGSTOP: press ctrl + z on the keyboard to pause a program.
The number above is the signal code, and the SIG * is the signal. These two are equivalent.
Process Management commands: kill, killall, pkill, and xkill
So how do we send a signal to a process? Kill, killall, pkill, and xkill are required. Let's take a look at how they use it.
Kill applications are used together with ps or pgrep commands;
Kill usage:
Kill [Signal] [signal code] process ID
Note: It is okay to use one signal or signal code.
For example
[Root @ yufei ~] # Ps auxf | grep httpd
Root 3890 0.0 0.3 103228 864 pts/0 S + \ _ grep httpd
Root 3879 0.5 4.1 281892 10220? Ss/usr/sbin/httpd
Apache 3881 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3882 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3883 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3884 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3885 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3886 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3887 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3888 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
The second column is the process ID, and we can see from 3879 that it is the parent process of the httpd server, and from 3881 to 3888 is the child process of the httpd server, if the sub-process is killed, it only takes effect for itself.
[Root @ yufei ~] # Kill-15 3888
[Root @ yufei ~] # Ps auxf | grep httpd
Root 3893 0.0 0.3 103228 864 pts/0 S + \ _ grep httpd
Root 3879 0.0 4.1 281892 10220? Ss/usr/sbin/httpd
Apache 3881 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3882 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3883 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3884 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3885 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3886 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3887 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
3888 this process is gone
If the parent process is killed, all child processes will be finished.
[Root @ yufei ~] # Kill-15 3879
[Root @ yufei ~] # Ps auxf | grep httpd
Root 3895 0.0 0.0 2644 168 pts/0 D + \ _ grep httpd
Start the httpd service again.
[Root @ yufei ~] # Service httpd start
Starting httpd: [OK]
[Root @ yufei ~] # Ps auxf | grep httpd
Root 3920 0.0 0.3 103228 860 pts/0 S + \ _ grep httpd
Root 3909 0.2 4.1 281892 10220? Ss/usr/sbin/httpd
Apache 3911 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3912 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3913 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3914 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3915 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3916 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3917 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
Apache 3918 0.0 2.2 281892 5548? S \ _/usr/sbin/httpd
[Root @ yufei ~] # Kill-1 3909