Bring Backgroud processes to foreground in terminal

If you are using Terminal and have sent some processes to background using Control+Z, use the following commands to bring them back to foreground.

Type ps -a to view all background processes with pid. Or type only jobs, to view them in order.

Type fg to bring the last process back to foreground.

If you have more than one process running in the background, do this:

$ jobs
[1] Stopped python
[2]- Stopped python
[3]+ Stopped python

Type fg %3 to send the python process back to foreground.

To suspend the process running in the background, use:

kill -19 %job_id.
the -19 signal is SIGSTOP (the signal sent by Control - Z) .

example: kill -19 %3.

To kill a python process either type exit() in python shell, or type Control+D

Leave a Reply

Your email address will not be published. Required fields are marked *