The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parent child Relation !! using awk/sed ??? varungupta UNIX for Advanced & Expert Users 0 01-29-2008 10:24 AM
Parent/Child Processes yoi2hot4ya Shell Programming and Scripting 2 05-31-2006 10:27 AM
parent and child process question? tosa High Level Programming 0 02-16-2005 11:04 AM
How hard can it be? ps child/parent velde046 Filesystems, Disks and Memory 2 05-25-2002 01:36 PM
what are parent and child processes all about? xyyz UNIX for Dummies Questions & Answers 1 04-26-2002 12:53 PM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-09-2003
Registered User
 

Join Date: Nov 2001
Location: Hawaii
Posts: 79
kill parent and child

Hello all,

I have gone through the search and looked at posting about idle users and killing processes. Here is my question I would like to kill an idle user ( which I can do) but how can I asure that all of his process is also killed whit out tracing his inital start PID. I have tried this on a solaris 8 system but, I seem to make the child process a zombie or hang because of what he was doing. Is there a clean way to do this?
Thanks
Forum Sponsor
  #2 (permalink)  
Old 01-09-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,354
To kill absolutely every process owned by a non-root user, su to that user and then use:
kill -9 -1
  #3 (permalink)  
Old 01-09-2003
Registered User
 

Join Date: Nov 2001
Location: Hawaii
Posts: 79
Thanks Perderabo,

What you suggested works great. But I did not fully explain myself. I have a guest account in which guest can use to log on to the server. But some guest do not log off thus the problem. I just want to kill only the select login in.

Here is a print out of who -uH

NAME LINE TIME IDLE PID COMMENTS
guest pts/5 Jan 9 08:11 2:48 10842 (cic2)
guest pts/6 Jan 9 10:44 0:02 11159 (cic4)
guest pts/7 Jan 9 08:56 0:35 11039 (cic65)

As per you suggestion I would use kill -9 -1 10842

But this will kill all users that are login. But I don't want to kill all login. Just guest at pts/5 from machine "cic2". I have looked at the man pages for kill but it does seem to talk about the addtional "-1" after kill -9. Thanks again
  #4 (permalink)  
Old 01-09-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,354
I never said anything about "kill -9 -1 10842". The command is:
kill -9 -1
press the enter key after the -1. Do not append other integers to this command.

The -1 is pid. Look at the man pages again. I sure have in my man pages.

Since you want to kill only some of a user's processes, you will need to track them down. Maybe a command like "ps -ft pts/5" will help.
  #5 (permalink)  
Old 01-11-2003
sanjay92
Guest
 

Posts: n/a
Re: kill parent and child

Quote:
Originally posted by larry
Hello all,

I have gone through the search and looked at posting about idle users and killing processes. Here is my question I would like to kill an idle user ( which I can do) but how can I asure that all of his process is also killed whit out tracing his inital start PID. I have tried this on a solaris 8 system but, I seem to make the child process a zombie or hang because of what he was doing. Is there a clean way to do this?
Thanks
I have used the following shell script to kill all child PID's for a given PID.

Code:
#!/bin/ksh
# This script will kill all the child process id for a  given pid
#Store the current Process ID
CURPID=$$

# This is process id, parameter passed by user
ppid=$1

if [ -z $ppid ] ; then
   echo No PID given.
   exit;
fi

arraycounter=1
while true
do
        FORLOOP=FALSE
        # Get all the child process id
        for i in `ps -ef| awk '$3 == '$ppid' { print $2 }'`
        do
                if [ $i -ne $CURPID ] ; then
                        procid[$arraycounter]=$i
                        arraycounter=`expr $arraycounter + 1`
                        ppid=$i
                        FORLOOP=TRUE
                fi
        done
        if [ "$FORLOOP" = "FALSE" ] ; then
           arraycounter=`expr $arraycounter - 1`
           ## We want to kill child process id first and then parent id's
           while [ $arraycounter -ne 0 ]
           do
             kill -9 "${procid[$arraycounter]}" >/dev/null
             arraycounter=`expr $arraycounter - 1`
           done
         exit
        fi
done
## Kill Parent ID
kill -9 $CURPID
added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 04:52 PM.
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0