Putting a process in the background without stopping it - (ctrl+z)? [closed]

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.


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://example.com/bigfile.iso) will NOT terminate! All of your shell sessions will be there waiting for you when you reconnect.

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