71. Process Management - kill and killall
Contents
The kill command can terminate the process by the process ID or name, and the killall command can terminate the process itself and its associated processes by the process name.
Options
kill Command Options
Here are some options for kill command:
Option | Description |
---|---|
-s or ‑‑signal signal | The number or name of the signal to be sent. |
-l or ‑‑list [number] | Output the number and name of available signals. |
-p or ‑‑pid | Show the process ID of the specified processes instead of sending any signals. |
‑‑verbose | Show the specified process IDs which signaled by the kill command along with the sent signal itself. |
killall Command Options
Here are some options for killall command:
Option | Description |
---|---|
-e or ‑‑exact | Match the full name of the program instead of the short name, and the content after 15 characters will be truncated. |
-I or ‑‑ignore-case | case insensitive. |
-g or ‑‑process-group | Terminates the group to which the process belongs. |
-i or ‑‑interactive | Ask the user to confirm when the termination operation is performed. |
l or ‑‑list | Lists all available signal names. |
-q or ‑‑quiet | Do not show message if no processes were terminated. |
-r or ‑‑regexp | Use regular expressions to match. |
-s or ‑‑signal or -SIGNAL | Send the specified signal instead of SIGTERM. |
-u or ‑‑user | Terminates processes belonging to the specified user. |
-v or ‑‑verbose | If the signal is sent successfully, a success message is displayed. |
-y or ‑‑younger-than | Match young processes that start after a certain time. Available units are: s=seconds,m=minutes,h=hours,d=days,w=weeks,M=Months,y=years |
-Z or ‑‑context | Processes that have security contexts that match the extended regular expression pattern. |
Examples
kill Command Examples
Output Available Signal IDs and Names
|
|
Kill Background Running Processes
|
|
killall Command Examples
Output Available Signal Names
|
|
Kill the Process and all Its Related Processes
We install nginx for this demonstration:
|
|
Output nginx running processes:
|
|
Terminating all processes:
|
|
References KILL(1), KILLALL(1)
Author Dong Chen
LastMod Fri Apr 12 2019