Here's what I want to do: I want to get a tree-formatted list of processes from ps (as when you do ps auxwwf
), but only of processes that are either owned by me, or are ancestors of processes owned by me. So if I own a bash process way down the tree, and it has ancestors owned by root, I want to see those root ancestors in addition to the ones I own. I do not want to see any process trees that do not contain any processes owned by me.
Is there any way to do this with ps's normal options, or do I need to write a script to parse the output?
Try
ps -ejH
that displays a tree of processes, based of father-sons links.edit
To see only your processes
This won't be very fast, but it seems to do the trick:
This depends on your os, but based on the ps command you gave I think this might work:
ps --user dirtside -uxxf
My take on this, using iteration instead of recursion (no worry that you'll overflow your stack):
ps_backtrace.sh