Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

If I start a process by typing it in normally at the command line, such as

wget http://site.com/bigfile.zip

and then decide I want to move that to the background, I know that I can use something like ctrl+z and then bg 1 (or jobs first if needed to get the id) to put it in the background.

My question is if there is a way to move a job from the foreground directly to the background without stopping it - like another shortcut besides ctrl+z that would do that.

I also realize that I can append & to the end of the original command to start it in the background, but the question is in regards to when you start a process in the foreground and then realize you want to move it to the background.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Yes, absolutely: screen(1) is the answer.

To get started, add screen -R to ~/.bash_profile or equivalent, log out, and log back in.

To continue what's running in the background, press Control-A then N. This will create a new terminal screen in the foreground while seamlessly continuing your running process on the background.

Press Control-A then " to get an interactive list of screens that you have open, or press Control-A then a number to switch directly to a specific screen.

Your original requirement was to be able to move a process to the background without stopping it. Screen has two additional benefits, and these are huge if you like to do multiple things at once:

  1. You can switch between processes much more fluidly than by using Control-Z, bg, fg, etc.
  2. If your terminal session gets disconnected, your processes (like wget http://site.com/bigfile.iso) will NOT terminate! All of your shell sessions will be there waiting for you when you reconnect.

For more information, read this screen tutorial, the screen(1) manpage, or the GNU Screen Manual.

share|improve this answer
1  
Just make sure you've got the screen package installed first :) –  George Tasioulis Oct 1 '11 at 17:08

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.