Article Directory
1. kill command
Command: kill -l
Role: to see the available process signals
Common signals:
Signal code | Signal name | Description |
---|---|---|
1 | SIGHUP | This signal makes the process shut down immediately, and then restart after re-reading the configuration file |
2 | SIGINT | The program termination signal is used to terminate the foreground process. Equivalent to output ctrl+c shortcut key |
8 | SIGFPE | Issued when a fatal arithmetic operation error occurs, including not only floating-point arithmetic errors, but also all other arithmetic errors such as overflow and division by 0 |
9 | SIGKILL | It is used to end the operation of the program immediately. This signal cannot be blocked, processed or ignored. Generally used to forcibly terminate the process |
14 | SIGALRM | The clock timing signal calculates the actual time or clock time. The alarm function uses the signal |
15 | SIGTERM | The signal to terminate the process normally, the default signal of the kill command. Sometimes if a problem has occurred in the process and this signal cannot terminate the process normally, we will try the SIGKILL signal, which is signal 9. |
18 | SIGCONT | This signal allows the suspended process to resume execution, this signal cannot be blocked |
19 | SIGSTOP | This signal can pause the foreground process, which is equivalent to typing the ctrl+z shortcut key. This signal cannot be blocked |
Tips: Use signals to determine whether your process is started, restarted, or terminated.
The commonly used signals are as follows:
1. Restart the service and recall the content of the configuration file. **Service httpd restart is often used in Linux. In the final analysis, the 1 signal is called. **Some processes cannot be killed by default, so they should be terminated forcibly at this time.
Commonly used 1 restart 9 forced termination 15 default termination There
are many system processes. When you encounter an unknown process, it is best not to touch him. Most processes are system processes and cannot be terminated directly. After termination, the system will directly crash. If you encounter a process you don't know, you can check it with Baidu first.
Command: kill -1 22354
Role: Restart the process
Command: kill -9 22368
Role: Forced to kill the process
2. killall command
Command: killall [选项][信号] 进程名
Function: Kill the process according to the process name.
Options:
-i: Interactively, ask if you want to kill a process
-I: Ignore the case of the process name
3. pkill command
Command: pkill [选项][信号] 进程名
Function: Terminate the process according to the process name.
Option: -t 终端号
Kick the user according to the terminal number (this is different from killall)
3.1 Propose users according to terminal number
Command: w
Function: Use the w command to query the logged-in users of this machine
Command: pkill -t -9 pts/1
Function: Forcibly kill the process logged in from the pts/1 virtual terminal
4. Summary
(1) Although the process termination command can terminate the process, it is not a standard stop command. If it is stopped, it is best to use service httpd stop. This is used when the normal method does not take effect.
(2) pkill removes the user based on the terminal number . There are multiple administrators that interfere with the operation, and the administrator with high authority will kick the administrator with low authority.