1

I made an alias to search for and display all of the processes associated with a specific user account that seem to auto initiate every time I log in, which are about 15 and through a process of elimination I found the parent process. Basically I want the alias to display, just the parent process and not the whole list, I know I will have to pipe but beyond that I'm not sure.

Example:

ps -u *someuser* | grep <parent process name/PID>

EDIT #1

This is not exactly related to the process tree in which I'm referring, but I opened a man page so I could paste the associated processes:

966 man pidof --- 
969 sh -c (cd '/usr/local/share/man' && (echo ".ll 12.8i"; echo ".nr LL 12.8i"; /usr/bin/gunzip -c '/usr/local/share/man/ --- 
970 sh -c (cd '/usr/local/share/man' && (echo ".ll 12.8i"; echo ".nr LL 12.8i"; /usr/bin/gunzip -c '/usr/local/share/man/ --- 975 sh -c (cd '/usr/local/share/man' && (echo ".ll 12.8i"; echo ".nr LL 12.8i"; /usr/bin/gunzip -c '/usr/local/share/man/ --- 
977 /usr/bin/less -is` how `kill 966` kills all the rest

closed as unclear what you're asking by slm, Anthon, jasonwryan, rahmu, Renan Nov 16 '13 at 17:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Can you include the pieces you've identified thus far? I'm not following you when you say, parent process. I know what that is, but I want to make sure we're talking about the same things. – slm Nov 16 '13 at 4:26
  • Sorry for my lack of clarity in the question. and also the my formatting issues on here. I will get the hang of this. – user52470 Nov 16 '13 at 4:42
  • You want the name of the process that's at the top of the tree, right? BTW, you can try using the command pstree. That might be avail. on OSX. – slm Nov 16 '13 at 5:58
  • That's absolutely what I want to do, it's not native to osx, but homebrew has it. Now just tell me how I mark the question as solved and we are in business. – user52470 Nov 16 '13 at 6:13
  • Let me know if that's enough in the A, I can add more if needed. – slm Nov 16 '13 at 6:24
0

You can try using the Unix command pstree to get a list of the process names in a tree structure.

Example

$ pstree
init-+-NetworkManager-+-dhclient
     |                `-2*[{NetworkManager}]
     |-abrtd
     |-acpid
     |-atd
     |-auditd-+-audispd-+-sedispatch
     |        |         `-{audispd}
     |        `-{auditd}
     |-autossh---ssh---ssh
     |-avahi-daemon---avahi-daemon
     |-bonobo-activati---2*[{bonobo-activat}]
     |-chrome-+-3*[chrome]
     |        |-chrome-sandbox---chrome-+-chrome-+-25*[chrome---3*[{chrome}]]
     |        |                         |        |-4*[chrome---4*[{chrome}]]
     |        |                         |        `-chrome---6*[{chrome}]
     |        |                         `-nacl_helper_boo
     |        `-31*[{chrome}]
...
...

You can also provide a username if you just want processes related to a particular user.

Example

$ pstree saml
autossh---ssh---ssh

bonobo-activati---2*[{bonobo-activat}]

chrome-+-3*[chrome]
       |-chrome-sandbox---chrome-+-chrome-+-25*[chrome---3*[{chrome}]]
       |                         |        |-4*[chrome---4*[{chrome}]]
       |                         |        `-chrome---6*[{chrome}]
       |                         `-nacl_helper_boo
       `-31*[{chrome}]

clock-applet---{clock-applet}
...
...

Not the answer you're looking for? Browse other questions tagged or ask your own question.