Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change back into a running process on Linux after you put it into the background

I have spawned a process with another application. I can see that it is running with:

ps -ef

How can I switch into that process as if I started it manually myself by entering the command into the console?

like image 220
Frank Vilea Avatar asked Aug 29 '11 19:08

Frank Vilea


2 Answers

If it's started from current shell, use standard job-control e.g.

$ jobs

$ gedit &
[1] 3341

$ jobs
[1]+  Running                 gedit &

$ fg %1
gedit
like image 167
Fredrik Pihl Avatar answered Oct 19 '22 00:10

Fredrik Pihl


Basically, you can only manage processes with job control that are children of your current shell, that is, jobs started by the shell you are working with. If you did start and background the process with your current shell, fg and the other job control options will work. If not, you cannot manage the job with the shell.

The mostly used "workaround" (actually much more powerful than the shell) is GNU screen.

like image 42
thiton Avatar answered Oct 19 '22 00:10

thiton