Kill command is used to kill a process in Linux.The kill command sends the specified signal such as kill process to the specified process. If no signal is specified, the SIGTERM signal is sent.
Syntax:
kill [signal] PID
A list of common signals:
Example:
In example, we are terminating process java with -15 signal, which will terminate the process safely.
Points to remember:
Syntax:
kill [signal] PID
SIGHUP-(1) | Hangup detected on controlling terminal or death of controlling process. Use SIGHUP to reload configuration files and open/close log files |
SIGKILL-(9) | Kill signal. Use SIGKILL as a last resort to kill process. This will not save data or cleaning kill the process |
SIGTERM-(15) | Termination signal. This is the default and safest way to kill process |
Example:
In example, we are terminating process java with -15 signal, which will terminate the process safely.
Points to remember:
- You can kill all your own process.
- Only root user can kill system level processes.
- Only root user can kill process started by other users.
To kill multiple process in single command, mention all PID's in command:
kill -15 PID1 PID2 PID3
To kill process with its name:
You can kill any process by specifying its full name or partial name. So there is no need for you to find out the PID of the process to send the signal.
pkill java
Further, you can also kill process with its name using killall command but with killall, you need to specify full name of process.
Note: There are many kill signals that each serve a particular purpose. Typing "kill -l" will list the kill signals.
No comments:
Post a Comment