[kwlug-disc] Parent Processes
zixiekat at gmail.com
Tue Jan 25 14:05:24 EST 2011
That just leaves me with:
My earlier way is working, even if it's a for loop.
for i in `pgrep laFind.pl`
# echo "Looking at PID: $i"
ppid=`grep 'PPid:' /proc/$i/status | cut -f2 -d":" | sed 's/[\t]//g'`
if [ $ppid -eq 1 ]
echo "Found parent PID: $i"
echo "Child PIDs: `ps -o pid --ppid %i | sed s/[\n]/,/g`
Only issue I'm running into is removing newlines from a list and inserting a
comma. I have searched a lot for this and I swear I've done it before with
But it doesn't work. Neither does \n\r, \r or using a $. Using the $ just
sticks a comma at the end of each line.
On Tue, Jan 25, 2011 at 1:11 PM, John Van Ostrand <john at netdirect.ca> wrote:
> ----- Original Message -----
> > Ah! /proc/<PID>/status and look for 1 under PPid:, when you find all
> > the ones that have to do with search.pl and have a 1 for PPid, we're
> > all set.
> Now that I'm back at a computer this would work too:
> ps -e -o "%P %c" | grep -E "^ +1 " | grep search.pl
> Then pipe through sed or cut to get just the PID.
> John Van Ostrand
> CTO, co-CEO
> Net Direct Inc.
> 564 Weber St. N. Unit 12, Waterloo, ON N2L 5C6
> Ph: 866-883-1172 x5102
> Fx: 519-883-8533
> Linux Solutions / IBM Hardware
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the kwlug-disc