Linux kills process command __linux

Source: Internet
Author: User

The safest way to kill a process in a Linux operating system is simply to use the KILL command, with no modifiers, no flags.

First use the PS-EF command to determine the PID to kill the process, and then enter the following command:

# Kill-pid

Note: The standard KILL command usually achieves the purpose. Terminate the problematic process and release the resources of the process to the system. However, if a process starts a child process and kills only the parent process, the child process is still running and therefore consumes resources. To prevent these so-called "zombie processes", be sure to kill all of their child processes before killing the parent process.

Determine the PID or ppid to kill the process

# 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 has logged off. When this option is used, the kill command attempts to kill the left child process as well. But this command is not always successful-it may still be necessary to manually kill the subprocess before killing the parent process.

Term signal

Sends a term signal to the parent process, trying to kill it and its child processes.

# kill-term PPID

Killall command

The killall command kills all processes within the same process group. It allows you to specify the name of the process to terminate, not the PID.

# Killall httpd stop and restart process

Sometimes you just want to simply stop and restart the process. As follows:

# Kill-hup PID

This command shuts down the Linux gentle execution process and then restarts it immediately. This command is handy when you configure the application, and you can execute this command when you need to restart the process after modifying the configuration file.

Lore Kill-9 PID

Agreed to Kill-s SIGKILL

This powerful and dangerous command forces the process to terminate abruptly at run time, and the process cannot clean itself after it is finished. The hazard is that the system resources are not released normally and are not recommended unless otherwise available.

When using this command, be sure to confirm with ps-ef that there are no zombie processes left. Zombie processes can only be eliminated by terminating the parent process. If the zombie process is adopted by INIT, the problem is more 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 consumes a large amount of system resources, it is necessary to reboot the machine at some point to clear the process table.

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.