Kill

All posts tagged Kill

Kill Command

Of course most users know the kill -9 PID command.  However, normally kill -9 should be used as a last resort method.  Here are some other kill commands that most likely should be used first.

To HUP a process you can either,
$ sudo kill -HUP PID 
or
$ sudo kill -1 PID
To try to properly shutdown the process,
$ sudo kill -3 PID
To grab a full listing of what signals kill command has available,
$ kill -l 
or
$ kill -l 9
KILL
$ kill -l 1
HUP
Sometimes you deem it necessary to kill many processes at once.  For example lets say postfix gets hung….which I have seen a couple of times before.  You log on and notice about 100 hung postfix processes.  You try to stop postix and that hangs too.  Even kill -9 on the PID kills the parent but each child just turned into a PID.  You could do each kill -9 PID each individuallly…Ive been there before. ( or just get pissed off and do yourself some Windows troubleshooting (reboot!)).
Or
Next time you could try doing this.
for d in pidof posftix; do echo $d; sudo kill -9 $d; done
pidof finds all the pids for given binary, 
pidof postfix 
16612 16292 22578 25577 25766