Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-08-2004
Registered User
 

Join Date: Oct 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
kill the tty

Hello Experts
i'm having some trouble with a script.
the purpose is to kill all processes from a distinct tty in a HP-UX machine, given the User TTY.

it's to use like this:

killtty pts/tnb pts/tr pts/tD

here it is

#!/usr/bin/ksh
i=1
for i
do
[ ${i} ] || exit
kill -9 `ps -ft "${i}" | awk 'NR != 1 {print $2}'`
done

The problem is that it's leaving a zombie process, i don't know why.

i have adapted this script from one that Perderabo has indicated to me to kill all processes from a user given it's UserName.

Thanks for your help
Sponsored Links
    #2  
Old 04-08-2004
Perderabo's Avatar
Unix Daemon (Adminstrator Emeritus)
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,679
Thanks: 26
Thanked 238 Times in 148 Posts
A true zombie is not much of a problem. But look at the ppid field of the zombie. Do a ps "-fp n" where n is that ppid of the zombie. You will now be looking at the parent of the zombie. The zombie will persist until the parent issues a wait() system call. If the program is allowing zomblies to accumulate, it needs a fix. And you cam kill this parent process. That will reparent the zombie to init which will always wait for a dead child.
Sponsored Links
    #3  
Old 04-08-2004
Registered User
 

Join Date: Oct 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
well , let's see
when i use this script, it kill's all the processes but one.
the user still appears when i use "who" and with "w" in the column "what" i have "-".using "who -u" it has a process number.
and when i try to make "ps -fu" on that number , nothing appears.
i'm a bit confused about this, so i'l try to understand this a litlle bit more. thanks Perderabo
    #4  
Old 04-08-2004
Perderabo's Avatar
Unix Daemon (Adminstrator Emeritus)
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,679
Thanks: 26
Thanked 238 Times in 148 Posts
Quote:
Originally posted by vascobrito
"ps -fu" on that number , nothing appears.
i'm a bit confused about this,
ps -fp
Sponsored Links
    #5  
Old 04-08-2004
Registered User
 

Join Date: Oct 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
sorry, i ment to write ps -fp
when i write "who -u" , this appears:

dist12 pts/tc Apr 8 17:03 0:35 8145 132.142.170.33

then i try to:

"ps -fp 8145", but nothing appears, just column headers.

even when i write "ps -u dist12", nothing appears.

When i write "w", it appears among all other users

User tty login@ idle JCPU PCPU What
dist12 pts/tc 5:03 37 -

there must be some script error ,like if the script was killing the processes in the wrong order.
Sponsored Links
    #6  
Old 04-08-2004
Perderabo's Avatar
Unix Daemon (Adminstrator Emeritus)
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,679
Thanks: 26
Thanked 238 Times in 148 Posts
Huh? What on earth does "who" have to do with anything? A zombie is a process that has terminated. You use "ps" to see processes. In "ps -el", the second field, labelled S (for state) will have a Z for any zombies. So "ps -el | grep Z" will give you a list of all of your zombies...if you actually have some.
Sponsored Links
    #7  
Old 04-08-2004
Registered User
 

Join Date: Oct 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
well , i usualy use "who" to find who is logged.
when that line appears...

User tty login@ idle JCPU PCPU What
dist12 pts/tc 5:03 37 -

with that "-" in 7 column, the user isn't logged and i can't kill him any way, everything i try it's unusefull and the olny process number i can get is when i use "who -u". In this case it shows :

dist12 pts/tc Apr 8 17:03 6:42 8145 132.142.170.33

the number "8145" is the only PID that i find.

i don't know if this is a zombie, but i sure can't do anything with it.

as to knowledge about Unix or Scripting, don't be surprise about my ignorance. I only started while ago to learn.

and you have been most helpfull Perderabo
thanks for that
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Diff b/n kill and kill -9 ammu UNIX for Advanced & Expert Users 2 07-18-2007 05:29 PM
kill(0,-9) don't kill the process umen Programming 9 06-19-2007 06:09 AM
not able to kill find with kill -9 Amardeep UNIX for Dummies Questions & Answers 5 01-04-2007 04:49 PM
KILL PID, intern should kill another PID. rkrgarlapati Shell Programming and Scripting 4 10-17-2006 07:47 AM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 04:24 PM



All times are GMT -4. The time now is 03:51 AM.