Last night i started downloading all of Fedora core via rsync. It was getting late, so I put it in the background and logged out. i just logged in this morning, and wanted to see where it was at, so I typed “jobs”, but surprise, it isn’t there. I know it’s still running, because the lights on my hub are still blinking, it shows up in “top”, and i can see (du -bs fedora/) that the folder is still growing. How do i get the output back on my terminal?
First, the bad news. Once you’ve disassociated a running application from an input or output device, you can’t get it back. Hopefully it’s all working without a glitch so that’s not a big problem.
Now, let me explain what happened with your Linux process and show you how to avoid this problem in the future.
When you log in to your computer, your shell creates three I/O channels that are then used by all running applications spawned by (that is, launched from within) the shell unless specified otherwise. They are stdin (standard input), stdout (standard output, for all non-error message output), and stderr (standard error, only for error messages).
When you launched the rsync process, it was assigned the same three channels as an ls or who command would have been given. Since rsync doesn’t require any input, that was safely ignored, but as you know, stdout was going to your terminal window or screen.
Putting the job into the background, accomplished by the commands ^Z and bg, severed the ties with the three I/O channels, but most likely if the program had any input or output needs, it would have gone into what’s called an I/O Block state and output a message like “stopped (waiting for input)” on your screen. Of course, you might have set your login shell to ignore those I/O blocks, in which case output from background jobs just pours onto your screen, regardless of what you’re doing.
In either case, once you logged out, the three I/O channels were destroyed, even though they were ostensibly in use by your background job. Instead, the OS typically reassigns the channels to /dev/null, meaning that while rsync keeps chugging along, it can’t get any input (not a big deal) but can’t produce any visible output either.
Now, to avoid this problem in the future, the classic Unix way to push a job into the background is to redirect its important I/O channels along the way (well, its output channels). Here’s how I would have done it:
Then, if you want to watch it working, simply use:
and it’ll be as if you were running it directly, but it’ll survive you logging out and logging in again.
I hope that’s helpful for you, and good luck with Fedora Core too. Oh, and one last thought: you might find my best-selling book Teach Yourself Unix in 24 Hours good supplemental reading too.