kill -KILL -1


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers kill -KILL -1
# 1  
Old 09-17-2005
kill -KILL -1

Here is the scenario:

Using a client server, I log into various other servers on our network opening multiple terminals to monitor processes. Once I ssh into these servers as myself, I ssh in as another user. Sometimes I set up while -1 loops to monitor various processes. At the end of the day, I use the 'kill -KILL -1' command to kill my logins and processes associated with my logins. I've noticed the user I 'su' to has defunct processes and these processes seem to be increasing each time I logout at the end of the day. I've verified this by executing a:

ps -ef | grep user | grep defunct | wc -l

Is there a command that I can safely use that will shutdown all my processes that I opened and avoid these defunct processes? Hopefully, I've provided enough information so you all can help to answer my question.

Thanks in advance.
# 2  
Old 09-19-2005
Unless you disowned them from your shell, I imagine they'd get killed when you logged out. If you are disowning them, maybye you shouldn't, afterall, that's one thing the shell's there for. Keeping them in the shell should be better for not leaving defunct processes; having the shell quit before they do leaves them hanging when they quit, there's nothing to 'catch' them.
# 3  
Old 09-20-2005
kill -KILL -1 command

Thanks for the reply.

My previous understanding was that I could execute the subject command and the command would close the shell and kill all processes associated with the shell, but from my readings on this forum and reading a liitle more in some other books, I've come to find that although one may kill the shell, the processes that were opened as another user within the shell will continue to run as zombies or defunct processes.

My desire was to learn commands or execute a script that would kill all PPIDs and PIDs at the same time. I think it is just a waste of time to sit and exit out of every terminal at the end of my workday and believe me I open many when I'm at work, so if anyone knows safe commands or a script that I could use, I'd certainly appreciate it. That would help me to avoid these defunct processes and use UNIX the way it was intended (make my job easier).

Thanks....
# 4  
Old 09-20-2005
Quote:
Originally Posted by micklskot
Thanks for the reply.

My previous understanding was that I could execute the subject command and the command would close the shell and kill all processes associated with the shell, but from my readings on this forum and reading a liitle more in some other books, I've come to find that although one may kill the shell, the processes that were opened as another user within the shell will continue to run as zombies or defunct processes.
They're not running, they're dead. They're just stuck in the process table because their parent processes, the things that need to deal with them, have been killed too. That's why some signals are catchable, and why -KILL should be used only as a last resort; things like shells will catch SIGTERM and gracefully deal with terminating their child processes before exiting, while SIGKILL kills them and leaves their zombie children hanging. Now there's a mental image.

There are two things you can do, from what I know.
  • Disown these processes from your shell so that init is able to deal with them
  • Give your processes SIGTERM first, wait a bit, then give SIGKILL to processes that won't die
The latter is probably a more elegant way to do it, and the procedure I see linux do when shutting down... You don't want to use -KILL unless you absolutely need it, 'cause it can make a big mess.
Code:
#!/bin/sh

echo "Sending processes SIGTERM"
kill -TERM -1
sleep 5
echo "Sending remaining processes SIGKILL"
kill -KILL -1


Last edited by Corona688; 09-20-2005 at 03:18 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

2. Solaris

Cannot kill a process with kill -9

Hello everyone, I have a process that I want to kill. I have tried kill-9 PID but it doesn't work. I have tried preap PID but it doesn't work too. The parent of my process is the process whose PID is 1, so I can't kill it. My OS is a Solaris 9. Can anyone help me understand what's going... (3 Replies)
Discussion started by: adilyos
3 Replies

3. UNIX for Dummies Questions & Answers

kill -9

i want know the the diffrence between kill and kill -9 (3 Replies)
Discussion started by: rupesh.bombale
3 Replies

4. Linux

Kill a process without using kill command

I want to Kill a process without using kill command as i don't have privileges to kill the process. I know the pid and i am using Linux 2.6.9 OS. (6 Replies)
Discussion started by: sudhamacs
6 Replies

5. Shell Programming and Scripting

Kill a process without using kill command

Sorry, posted the question in other forum. (0 Replies)
Discussion started by: sudhamacs
0 Replies

6. UNIX for Advanced & Expert Users

Diff b/n kill and kill -9

Hi, I have a process with say pid x. What is the difference b/n kill x and kill -9 x in unix Thanks Ammu (2 Replies)
Discussion started by: ammu
2 Replies

7. Programming

kill(0,-9) don't kill the process

Hi all i have simple c program , when i wish to kill the app im using kill(0,-9) , but it seams this command don't do any thing and the program. just ignore it . what im doing wrong here ? im using HP-UX ia64 Thanks (9 Replies)
Discussion started by: umen
9 Replies

8. UNIX for Dummies Questions & Answers

not able to kill find with kill -9

Hello everyone I am using HP Ux and had run a find command. Now I am trying to kill it with kill or kill -9 but it is not getting killed and still running. Any clues ? Thanks Sidhu (5 Replies)
Discussion started by: Amardeep
5 Replies

9. Shell Programming and Scripting

KILL PID, intern should kill another PID.

Hi All, In my project i have two process runs in the back end. Once i start my project, and execute the command ps, i get below output: PID TTY TIME CMD 9086 pts/1 0:00 ksh 9241 pts/1 0:02 java 9240 pts/1 0:00 shell_script_bg java with 9241 PID is the main... (4 Replies)
Discussion started by: rkrgarlapati
4 Replies

10. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies
Login or Register to Ask a Question