If you care display the process tree for a given PID, check out pstree on linux and Solaris. On solaris, pstree is part of the /proc virtual file system.
Thanks Gregor, that looks interesting and I'll certainly try it out.
Another problem I'm trying to solve right now is another
post I made on the same day. I need to be able to trap
the message that the AT command sends to the terminal when
submitting a command to the AT utility queue.
You know the one that says something like...
Job user.xxxxxxxxx.a will be run at datetime
I tried different variations of setting output, but nothing
seems to work.
Thanks, but that isn't what I was asking at all.
I wanted to capture the message that AT gives when you
run a command under AT.
I know how to do "at- l" to get a list. Unfortunately,
as part of "at -l" you don't get the actual name of
the shell that AT will be running, unless you have privileges to get to the cron/atjobs file.
What I need to do, without privileges, is to associate
the actual shell being submitted with the AT job name
you see with "at -l". I just got it working, and what
I am doing is sending standard error to a file, then AT
writes the message with the job name to this file. I then
cut the AT job name from that file and create another temporary file, where I write the AT job name and the
actual shell name I had stored in a variable.
Problem solved, I can then read this file, present a
listing to the user with the name of the shell they
will recognize, and after they select the job to delete,
it will use the nonsense name given by AT to delete the job
from AT.
Excellent script, Gregor.
It finds all chld processes and grandchilden too!
You may want to consider adding a sort statment.
When I did this it was much easier to trace
the lineage when there were a lot of child processes.
Also, maybe add this script as a faq.
It's going to take a while to digest your script
to tell you exactly how to do it.
But I just mean to sort the child pids that you find.
So the grandchildren appear below their parents
instead of the order being mixed up.
child [pid]|sort
works somewhat but, it also sorts the master PID
and the ===== etc.
Robert
Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
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.