How to Kill a Linux Process by ID

How to Kill a Linux Process by ID thumbnail
Use the kill command to force an out of control process to terminate.

As with all computer software, bugs and unpredictable events can cause Linux processes to crash, stopping programs from working and often using up large amounts of CPU resources and memory. If a process stops responding or goes out of control, you can use the kill command to shut down the process in a variety of ways that increase in severity. Once you have killed the process, you can restart the program after investigating the cause of the crash.

Instructions

    • 1

      Log in to the Linux server using SSH if you are using a remote server, or open a terminal window if you are working on the computer.

    • 2

      Find the ID number of the process you want to kill. A list of running processes can be seen by typing "px -aux" at the terminal prompt, which displays the name of each process and its process ID. Type "top" at the terminal prompt to see a real-time display showing running processes and IDs, and the amount of CPU time and memory each is using. This information is useful to see any out of control processes. Press "q" to quit top and return to the terminal prompt.

    • 3

      Type "kill process_id" at the terminal prompt to kill a specific process, replacing "process_id" with the relevant process ID number. The kill command will attempt to shut down the process cleanly.

    • 4

      Type "kill -1 process_id" at the terminal prompt if the kill command on its own could not shut down the process. The "-1" parameter tells the process to quit as though a log out were occurring, and attempts to kill off any child processes.

    • 5

      Type "kill -9 process_id" at the terminal prompt if previous attempts to shut down the process have failed. This will force the process to die, but may leave some child processes running as it is not a clean shut down. If any child processes remain, you can kill them manually if required.

Tips & Warnings

  • Once you have killed an out of control process, look at the log files for the program to try to determine the cause.

Related Searches:

References

Resources

  • Photo Credit Polka Dot RF/Polka Dot/Getty Images

Comments

Related Ads

Featured