Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I sometimes start processes in the background using the terminal. For example:

$ matlab &

Some hours later, I cannot remember which Terminal I began matlab from, i.e. which Terminal is not safe to close.

How can I check in a Terminal to see what child processes it has spawned (if any)?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The jobs command will list all background jobs launched from the shell you type it in.

share|improve this answer
    
Great, just what I was looking for. Thanks. –  Bill Cheatham Nov 14 '12 at 18:20

Probably the best way (apart from Dennis's answer) is with the well-known and widely used command:

ps -e -o pid,ppid,args --forest

Then you can see quickly the pid of the terminal that has launched various processes, and the processes themselves:

 3494  3490  \_ gnome-pty-helper
 3495  3490  \_ bash
 3566  3495  |   \_ evince
 3578  3490  \_ bash
 3684  3578  |   \_ man ps
 3693  3684  |       \_ pager -s
 3709  3490  \_ bash
 3801  3709      \_ /usr/bin/python /usr/bin/meld
 3871  3709      \_ ps -e -o pid,ppid,args --forest

For a particular terminal, enter ps -T in that terminal:

 PID  SPID TTY          TIME CMD
 3709  3709 pts/3    00:00:00 bash
 3801  3801 pts/3    00:00:00 meld
 3882  3882 pts/3    00:00:00 ps

For more information on ps, see man ps or the Ubuntu manpages online. There are some very interesting and extremely useful ps combinations that can be made. I was inspired by some of the examples in this article, and continue to experiment with different combinations.

share|improve this answer
    
Definitely an interesting command, but probably overkill for my use! Could come in handy in the future. –  Bill Cheatham Nov 14 '12 at 18:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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