Possible Duplicate:
How can I disown a running process and associate it to a new screen shell?
I launched a command that lasts a long time.
I had to disconnect so I moved it in the background (with CTRL+Z and bg) before exiting.
Something like this:
$ my_command ***command is beeing executed and is taking a long time*** ^Z [1]+ Stopped my_command $ bg [1]+ my_command & $ exit
I reconnected and can see the command in the process list but cannot recover with fg.
$ fg -bash: fg: current: no such job
How do I recover my job in the foreground?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
If you’ve already started something somewhere, backgrounded it, and now need to attach it to a new terminal, you can use reptyr to re-attach it. (The man page summarises the command as “Reparent a running program to a new terminal”.)
The reason you can’t see it in the “jobs” command or use “fg” to bring it to the foreground is because these commands are actually built-in to the shell. They don’t technically detach the processes from the terminal you’re connected with, so when you exit the shell they should exit as well (you should get a warning when you attempt to exit).
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0