The safest way to kill a processThe kill command is used without a modifier or a flag.
First, use the PS-Ef command to determine the PID of the process to be killed, and then enter the following command:
# Kill-PID
Note: Standard kill commands can achieve the goal. Terminate the problematic process and release the process resources to the system. However, if a child process is started and only the parent process is killed, the child process is still running and consumes resources. To prevent these so-called "zombie processes", ensure that all child processes are killed before the parent process is killed.
Determine the PID or ppid of the process to be killed
# Ps-Ef | grep httpd
End the process in an elegant way
# Kill-l PID
The-L option tells the kill command to end the process as if the user who started the process had logged out. When this option is used, the kill command also tries to kill the left child process. But this command is not always successful-you may still need to manually kill the child process and then kill the parent process.
Term Signal
Send a term signal to the parent process, trying to kill it and its child process.
# Kill-term ppid
Killall command
Killall command to kill all processes in the same process group. It allows you to specify the name of the process to be terminated, rather than the PID.
# Killall httpd
Stop and restart Processes
Sometimes you only want to simply stop and restart the process. As follows:
# Kill-HUP PID
This command causes Linux to shut down the slow execution process and then restart immediately. This command is convenient when you configure the application. You can execute this command when you need to restart the process after modifying the configuration file.
Kill-9 PID
Agreed kill-s sigkill
This powerful and dangerous Command forces the process to terminate suddenly at run time, and the process cannot be cleaned up after it ends. The hazard is that the system resources cannot be released normally. It is generally not recommended unless other methods are ineffective.
When using this command, you must use PS-Ef to confirm that no zombie process is left. Only the parent process can be terminated to eliminate zombie processes. If the zombie process is adopted by init, the problem will be serious. Killing the INIT process means shutting down the system.
If there is a zombie process in the system, and its parent process is INIT, And the zombie process occupies a large amount of system resources, you need to restart the machine at some time to clear the process.
This article is from the "wdejiyi1210" blog, please be sure to keep this source http://3635076.blog.51cto.com/3625076/1544842
Shell kill Process