Archive for the tag 'Kill'

SBDavid

kill - terminate a process

kill - terminate a process

The command 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 use the KILL (9) signal, since this signal cannot be caught.

Most modern shells have a builtin kill function, with a usage rather similar to that of the command described here. The `-a’ and `-p’ options, and the possibility to specify pids by command name is a local extension.

$ kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
………
………

Negative PID values may be used to choose whole process groups; see the PGID column in ps command out?put. A PID of -1 is special; it indicates all processes except the kill process itself and init.

EXAMPLES

kill -9 -1
Kill all processes you can kill.

kill -l 11
Translate number 11 into a signal name.

Kill all processes matching certain strings.

This guide will help you to know how to kill all processes matching certain strings, for our example we will use httpd.

One very simple method is killall, such as

killall -9 httpd

If that doesn’t work you can go through the process list and kill -9 the pids by using the following,

kill -9 $(ps aux | grep -v grep | grep httpd | awk ‘{print $2}’)

Where httpd is the string.