write sh or ksh NOT csh scripts. -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
umm ... not quite ... it is written incorrectly and returns the PPID without the first character.
so a PPID of 55234 is returned as 5234 ... which probably isn't owned by you ...
if you have a PPID of 51 and you were root ... and especially if you tried the infamous 'kill -9' which i'm sure jamisar will tell you you should never do ;P then you might have a little problem with your machine
which leads me to the question:
"what is it you're trying to do?"
Ok guys.I think its the worst criticism ive ever got so far but i understand it might be deserving too.Anyway here is what i am trying to do.I am trying to kill all the processes that belongs to my user id.Please send me the whole code with the loop and variable declaration cause i am not familiar with unix at all.
It's theoretically possible, but such a script may not work properly all of the time.
If you have a script that goes through the process list killing all processes owned by the current user, eventually it will get to the process that is doing the killing, suicide, and thus not go any further, possibly leaving some other processes behind.
Thanks Chapter11,yes ur right it does suicide and stop the process and kills itself.But somehow i have to do this.Meanwhile i tried this command
ps -ef | grep $USER which returns the processes of the current user.This returns 2 columns of Process ids like below
It won't be quite that easy. If you just filter out one process, you may still kill a parent or child of your script.
Try this ksh snippet:
[tt]MYTTY=`tty | cut -b 6-`
# you may need to adjust the cut values, you want MYTTY to look like "pts/17"
# assuming the current userid is stored in ${USER}:
ps -ef | grep ${USER} | grep -v ${MYTTY} | while read OWNER PID MISC
#^ Get all processes
# ^ just look at mine
# ^ filter out my processes attached to my current terminal
do
kill ${PID} # or -9 it if you like
done
Thanks Chapter11 i will try that out,i am working in CSH so i will convert it into that and do it.Will let u all know if this one works.But the bottomline is i am executing a FTP process and once its done i am killing the processes which is what i need to do.But the complication lies in killing all the proceses in the loop and as u said its not easy and it does hang while doing it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.