> ps -ef | grep $1 | grep -v grep | nawk '{print "kill -9 " $2}' | sh
No no no. Don't use kill -9.
It doesn't give the process a chance to cleanly:
and so on and so on and so on.
Generally, send 15, and wait a second or two, and if that doesn't work, send 2, and if that doesn't work, send 1. If that doesn't, REMOVE THE BINARY because the program is badly behaved!
That would be "regular" kill sig (TERM), then INT, then HUP. Incidentally, with certain irritating programs at our site, I have to use USR1. Most programmers forget to block out USR1, while it is common to stupidly block out HUP.
Don't use kill -9. Don't bring out the combine harvester just to tidy up the flower pot.
Randal
Back in 92 when I was working for Telebit, a co-worker asked me how to stop and start getty on SunOS 4.x. I told him "kill -1 1", but he lost track and typed "kill 1 -1". His init process went badda-boom.
After that, I started telling people the command was "kill -HUP 1", so it would be harder for them to get them out of order.
Greg
Another exciting story: I enjoy Linux "killall" command. I once worked on Solaris as root. I was very new in Solaris, and I wondered if "killall" existed there, too. So I foolishly typed "killall" just to check it. It turned out that "killall" is present on Solaris but it does something quite different than on Linux. Hard reboot was all I could do.