Linux - Different methods to kill process, Killing a process using different methods
Different methods to kill processThere are different methods to kill a process.
To kill a process you must specify the process id, before killing a process.
# kill -TERM pid # kill -SIGTERM pid # kill -15 pid
How to find the process id?
# ps -ef | grep firefoxThe above command will list the process id of firefox
user 21169 21145 0 10:28 pts/4 00:00:00 /bin/sh /usr/lib/firefox-3.0.19/firefox user 21186 21169 0 10:28 pts/4 00:00:02 /usr/lib/firefox-3.0.19/firefox user 21851 21145 0 12:25 pts/4 00:00:00 grep firefox
After finding the process, kill the process by specifying the process id.
# kill -9 21186
Linux Killall Command - To kill process by its name
Instead of specifying a process by its PID, you can specify the name of the process. If more than one process runs with that name, all of them will be killed.
Example: Kill all the firefox processes
# killall -9 firefox
Pkill Command - Send signal to the process based on its name
You can send signal to any process by specifying the full name or partial name. So there is no need for you to find out the PID of the process to send the signal.
Example: Send SIGTERM to all the process which has sample in its name.
# pkill samplePkill Example:
Before sending signal, you can verify which are all the process is matching the criteria using "pgrep -l", which displays the process ID and process name of the matching processes. In this example, all the processes are designed to log the signal to signal-log, along with its PID.
# pgrep -l sample 12406 sample-server.p 12425 sample-server.p 12430 sample-garbagec
# pkill -USR1 sample
# cat signal-log Name: ./sample-server.pl Pid: 12406 Signal Received: USR1 Name: ./sample-server.pl Pid: 12425 Signal Received: USR1 Name: ./sample-garbagecollector.pl Pid: 12430 Signal Received: USR1Note: The part of name which you specify should be in the character within the first 15 character of the process name.
The topic on Linux - Different methods to kill process is posted by - Math
Hope you have enjoyed, Linux - Different methods to kill processThanks for your time