Be Careful With Kill
Posted on February 7, 2007 7:41 AM
I was reading a useful article called Web Developers: 13 Command Line Tricks You Might Not KnowMost of the stuff there is pretty good, although in true Computer Geek form, I already knew that.
I did take exception to one section of that post however:
| Quote: |
The -9 basically kills the process with extreme prejudice, it will die immediately. |
Boy, as a sysadmin type I hate it when I see people say this. They make it sound like kill -9 is just a more powerful kill, like a higher caliber bullet or something. kill -9 should not be the default kill command you use. You should try using kill without -9 first, since when you use the -9 option, it will leave behind child processes that then run until they die or the next reboot. kill -9 means die now and don't clean up anything.
If you issue the kill command and the process doesn't die right away, it may be trying to clean up, especially if you're killing a command-line database script.
That being said, kill -9 CAN be used when you kicked off a process 2 hours ago that runs for 6 hours, and you want to go home for the day. Just ctrl-z the proc and then bg it, then you can kill -9 the shell that called it, which should leave your background process running. This can be useful for doing a fire and forget ftp download, if you don't have access to screen or vnc or something.
Add/View Comments (1) Tags: cli, command-line, kill, unix
