Re: [SLUG] Is there a shell one liner to do this?

From: Paul Braman (aeon@tampabay.rr.com)
Date: Tue Apr 10 2001 - 18:40:06 EDT


On Tue, 10 Apr 2001, Michael Manchester wrote:

> I was wondering if there is a shell oneliner that can
> take the ouput of ps -A and piping through grep or awk
> kill process that match a search string.
>
> Sometimes netscape leaves a number netscape-common
> process running. When this happens I have to kill all
> of these before netscape will start again. I'm looking
> for a quick easy way to kill all of these process from
> the shell prompt.

Here's some free Unix advice.

I've seen a lot of people reply to this post with a "kill -9" statement.
My free advice is that you learn to use words instead of numbers.

Now, the option to the kill command is the signal number or signal name
you want to send to the program. It is my belief that it is far easier
and more portable to remember the name of a signal you want to send (which
extends from why you are sending it) then it is to remember which number
that signal maps to.

For example, on most systems, the number 9 represents the SIGKILL signal.
Hence, you would write a command like "kill -KILL" instead of the
aforementioned erroneous method.

Now, you'll get a whole lot of stubborn people saying that it doesn't make
a difference and that "everyone knows what kill -9 does", but what if you
want to make a running process abort and dump a core file? The way I do
it is by sending the SIGABRT signal via "kill -ABRT". Can *everyone* that
uses "kill -9" tell me which signal number SIGABRT is? I personally don't
remember, and don't need to; neither should you.

Another reason for using names instead of numbers is that the signals
actually mean something. For instance, SIGUSR1 and SIGUSR2 are
user-defined signals, SIGKILL is a signal that cannot be caught or
ignored, SIGHUP tells the process to "hang up" or "restart" typically, and
SIGABRT tells a process to dump a core file and stop. If you used numbers
for all of this you would first have to remember the name of the signal
you wanted to send and then have to remember (or look up) which signal
this maps to. Boy, that's a lot more work than I care to do, being a
user.

Remember, use names instead of numbers. It's the right thing to do and a
tasty way to do it. :)

kill -TERM

Paul Braman
aeon@tampabay.rr.com



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:26:50 EDT