Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

marked as duplicate by Mat, Renan, jasonwryan, Gilles, warl0ck Sep 26 '12 at 0:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer 1

up vote 5 down vote accepted

If you've already started something somewhere, backgrounded it, and now need to attach it to a new terminal, you can use repytr to re-attach it.

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).

share|improve this answer
    
+1. thanks, i didn't know about repytr. useful....doing what it does manually always seemed too much work to be worth the effort most of the time. –  cas Sep 25 '12 at 22:53
    
works so great... !!! thanks!!! sometimes you need to use 'sudo' to run the command. syntax: "sudo reptyr –s PID " and it brings my python process from other terminal active in the current one. –  ihightower Dec 13 at 11:08

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