1840081 Members
2686 Online
110161 Solutions
New Discussion

"kill" command .

 
Hell.Leader
Occasional Advisor

"kill" command .

What's the difference of ???kill pid??? and ???kill ???9 pid????
TKS!
HPcert
6 REPLIES 6
harry d brown jr
Honored Contributor

Re: "kill" command .

OUCH!

kill pid, allows the process (if written correctly) to die gracefully.

kill -9 pid is like killing a fly with a daisy cutter (that 15,000 pound bomb). It can cause database corruption and other issues. Should only be a last resort!

live free or die
harry
Live Free or Die
Michael Tully
Honored Contributor

Re: "kill" command .

Hi,

The main difference is killing the pid
gracefully and hopefully the process
cleans itself up and closes files. Using
the kill -9 option is hitting the process
with a sledge hammer. In other words don't
use it unless you have to. On a lot of
occassions using -9 does not clean up.

If you want to kill a process try this order:

# kill pid
# kill -5 pid
# kill -9

-Michael
Anyone for a Mutiny ?
Roger Baptiste
Honored Contributor

Re: "kill" command .

kill -9 is killing without any mercy i.e. it shuts the
process irrespective of what
it is doing.

Whereas the other kill is a graceful kill .

use kill -9, only when the
other kill does not work and you really want to kill.

Ooph, too many kill''s here.

-raj
Take it easy.
Bill Hassell
Honored Contributor

Re: "kill" command .

kill actually does not perform any termination of a process--it is really a signal program that places a signal into the process table for the listed process(es). There are many kill signals: kill (no option) or kill -15 (which is the default for kill) and kill -s SIGTERM (another way to specify kill signals) is the least intrusive. Properly written programs and scripts will trap this signal and perform an orderly shutdown of the process.

However, if a process ignores the kill signal then nothing happens with kill -15. Other kill signals are kill -1 (or SIGHUP) which is sent automatically when a disconnect (hang up as in a modem) occurs, kill -2 (or SIGQUIT) which causes a process to core dump, and so on.

In fact, signals can be detected and the process can continue on...it is just a signal. An example is kill -SIGKILL $(cat /var/run/syslog.pid) which causes syslogd to reread it's config file. named uses several kill signals including SIGUSR1 and SIGUSR2.


Bill Hassell, sysadmin
Sanjay_6
Honored Contributor

Re: "kill" command .

Darrell Allen
Honored Contributor

Re: "kill" command .

Look at the man page for signal for a list of them. Some can be trapped by the process and coded to perform whatever task one desires. That includes the default signal 15 sent by kill pid. Others can not be trapped and the process has no choice in how to handle the signal. A kill -9 is one of those.

Darrell
"What, Me Worry?" - Alfred E. Neuman (Mad Magazine)