Computing.Net > Forums > Unix > Kill defunct process without root

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Kill defunct process without root

Reply to Message Icon

Name: Henk
Date: November 26, 2002 at 05:00:57 Pacific
OS: HP-UX 10.20
CPU/Ram: 3 1024
Comment:

Hello,

i have made a script who will kill all processe with defunct. but in the kill-list are the entry from my grep-command :-(

Itīs possible to extract the list without the root-user?

My svript:

#!/bin/ksh
PATH=/usr/bin:/bin
export PATH
user='defunct' #this could be a program name also
proclist=`ps -ef | grep $user | cut -c16-20`
rm -f /tmp/delpid
echo "cron script running on \c" >>/tmp/delpid
uname -a >>/tmp/delpid
echo "Following processes removed for $user" >>/tmp/delpid
date >>/tmp/delpid
echo "PASS 1 - cleanup" >>/tmp/delpid
for proc in $proclist;do
kill $proc
echo "kill $proc" >>/tmp/delpid
done
sleep 30 #wait thirty seconds to give stuff a chance to die
echo "PASS 2 - double check (should be blank below)" >>/tmp/delpid
proclist=`ps -ef | grep $user | cut -c16-20`
for proc in $proclist;do
kill -9 $proc
echo "kill -9 $proc" >>/tmp/delpid
done
mail admin_user # rm -f /tmp/delpid

thx
Henk



Sponsored Link
Ads by Google

Response Number 1
Name: Guy
Date: November 26, 2002 at 20:13:44 Pacific
Reply:

Try:

proclist=`ps -ef | grep $user | sed -e '/grep/d' | cut -c16-20`

G.


0
Reply to Message Icon

Related Posts

See More


Unix ls opinions login server for unix env...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Kill defunct process without root

Defunct processes www.computing.net/answers/unix/defunct-processes/3194.html

What is Unix? www.computing.net/answers/unix/what-is-unix/1763.html

Killing processes as root www.computing.net/answers/unix/killing-processes-as-root/1622.html