Command for shutting down processes in Linux

Source: Internet
Author: User
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: the Standard kill command can usually 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# The kill-l PID-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 SignalSend a term signal to the parent process, trying to kill it and its child process. # Kill-term ppid

Killall commandKillall 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 ProcessesSometimes you only want to simply stop and restart the process. Run the following command: # kill-hup pid to shut down Linux's slow execution process and restart it 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 PIDThe agreed kill-s sigkill powerful and dangerous Command forces the process to terminate suddenly at runtime, and the process cannot be self-cleaned after completion. 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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.