Kill command in Linux and how to force terminate a process

Source: Internet
Author: User

To work on Linux, you often need to use the kill command to stop the process. In general, you can use the ps command to find the process ID to be aborted and directly use "kill PID. However, this command occasionally becomes invalid and the process cannot be aborted. In this case, you need to have an in-depth understanding of the kill command to find a solution.

Let's take a look at the description of the kill command in Linux:
Description
      TheCommand kill sends the specified signal to the specified process or process group.If no signal
Is specified, the term signal is sent.

      The term signal will kill processes which do not catch this signal.For other processes, it may be necessary
To useKill(9)Signal,
 Since this signal
Cannot be caught.

      ...
It turns out that the kill command can send multiple different signals. By default, kill sends the term, that is, the 15 (sigterm) signal. The "kill PID" and "Kill-15 PID" are the same. This signal usually requires the program to exit normally, which is a safe method. However, it can be blocked, processed, and ignored, so some processes will stop and fail.
Another commonly used signal is sigkill. This command indicates that the program is terminated immediately and cannot be blocked, processed, or ignored. If the term signal fails, you can try "Kill-9 PID ". Use "Kill-L" to view more signal lists.

Although the "kill-9" command is very powerful, it may still fail to achieve the goal. At this time, another way is to use "PS-Ef" to find the parent process (ppid) of the process to be aborted, and then use the kill or killall command to kill it.

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.