b5media.com

Advertise with us

Enjoying this blog? Check out the rest of the Technology Channel Subscribe to this Feed

New Linux User

HOWTO: Use Job Control - Putting Processes in the Background

by Jon on May 11th, 2006

Putting a process or application in the background means that the process essentially detaches itself from the consol, but keeps executing. This frees up the console to do other things.

You can either put a process into the background immediately upon launch, or you can stop a process already running in the foreground and resume it in the background.

To start a process in the background

nano &
[1] 7594

The & sign tells Linux to run nano in the background and reports the job id [1] and the Process ID (PID) [7594].

If I want to get at nano to use it, I can type fg or fg 1.

If I was already running nano and decided later that I wanted to push it to the background, I can use Control-Z to stop nano and then the bg command to resume it in the background.

CTRL-Z
[1]+ Stopped nano
bg

POSTED IN: How To

3 opinions for HOWTO: Use Job Control - Putting Processes in the Background

  • Eric Coleman
    May 11, 2006 at 12:58 pm

    Why not use screen?

    screen
    type do whatever
    ctrl + alt + d (detach)

    then you can resume using screen -r

  • Jon
    May 11, 2006 at 1:02 pm

    That’s great if I know ahead of time that I’m going to want to bail out of what I’m doing. If I don’t, then I won’t have run screen, no?

    I haven’t run across screen yet so I may have its functionality wrong.

    My method always works regardless of whether I thought ahead or not :)

  • Eric Coleman
    May 12, 2006 at 1:50 am

    Setup your shell to autostart screen then… you always have a session available then ;)

Have an opinion? Leave a comment:




Check Spelling
Activate Spell Check while Typing