Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I know that I can run an application in the background by putting an ampersand ('&') behind the command. For instance:

user@ubuntu:~$ rtorrent &
[1] 4618

starts rtorrent in the background.

I'd like to return to the backgrounded rtorrent to check whether my downloads are completed. How can I do that?

share|improve this question
2  
jobs and fg or fg %n fg for 'foreground' –  jippie Oct 25 '12 at 20:44

2 Answers 2

up vote 5 down vote accepted

Run fg to put the job back onto the foreground, i.e. give it back control of the terminal. If there are multiple background jobs, run jobs to see a list and fg %1, fg %2, etc., to select which job to put back to the foreground. See the Wikipedia article on job control for more information.

If a program is running on the foreground, press Ctrl+Z to suspend it. When you do this, you'll get a shell prompt. Run bg to make the program keep running, but in the background.

If a background job terminates, the shell will print a notification the next time it displays a prompt. If a background job requires input from the terminal, it will automatically be suspended (“stopped”); fg (or fg %42 if necessary) resumes it.

If you want to trigger a more visible notification when the program finishes, you can run something like

fg; play bell.ogg & xmessage "torrents downloaded"

The fg command returns when the program that it resumes finishes, so whatever you told the shell to run after fg will run when the program finishes. Note that if you press Ctrl+Z to put the job back into the background, then the shell stops waiting and runs the following commands immediately.

share|improve this answer

You can just run the fg command in the terminal.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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