Results 1 to 5 of 5

Thread: Putting more commands behind an already running command

  1. #1
    Join Date
    Jun 2004
    The Matrix

    Putting more commands behind an already running command

    Ever had that you were building (/emerging/casting) something, but thought of more during the build? You can put the commands behind the running command by:
    1. Press Control+Z, the process is paused
    2. Run "fg ; command(s) you want to run"
    Beware though, once you press Control+Z again, the new commands start running so this only works once and you have to leave the process alone for the rest of the time.

  2. #2
    Senior Member
    Join Date
    Apr 2004
    Atlanta GA

  3. #3
    See also 'jobs', to list those stopped jobs, and 'bg', to put the process in the background.

  4. #4
    Join Date
    Apr 2004
    Atlanta, GA
    Yeah. Good idea to check jobs before doing the fg command as well, just in case you have something else backgrounded. Then you can fg by job nuumber.

  5. #5
    Join Date
    Nov 2004

    Re: Putting more commands behind an already running command

    A kind of short summary for % usage:

    Ctrl+Z: Pause and send to background.
    jobs: List background processes.
    %n: take the n'th process in `jobs` to foreground.
    %n &: load n'th process (in `jobs`) in the background (a kind of resume to Ctrl+Z pause.)

    When you want to resume a process in the background with &, sometimes it also dumps its output to foreground too. To escape from this situation you can run process as a child proc. (which we call as double penatration
    it's sth. like that:

    # first try this:
    > mplayer mudvayne.mp3 &
    # or
    > mplayer mudvayne.mp3 & 1> /dev/null 2>&1
    # as you'll see, it dumps its output to stdout.
    # stop above process and this time try this:
    > { mplayer mudvayne.mp3 & } 1> /dev/null 2>&1 &
    # but this time mplayer isn't listed in the `jobs`
    # it appears as a child process in `ps` output.

    for more information about this, you can take a look at ABS (advanced bash scripting) guide. (also, i should take a look at too

Similar Threads

  1. Putting multiple users in newly created group in one shot.
    By hrishikesh in forum Redhat / Fedora
    Replies: 0
    Last Post: 06-22-2008, 12:31 PM
  2. Replies: 5
    Last Post: 04-30-2007, 08:43 PM
  3. Running commands remotely
    By krinkstar in forum Linux - Hardware, Networking & Security
    Replies: 5
    Last Post: 01-11-2005, 02:05 AM
  4. running remote command, then leave it running
    By Blaqb0x in forum Linux - General Topics
    Replies: 1
    Last Post: 10-03-2003, 10:36 PM
  5. Hello & running a command when xsession is closed
    By Pierre_Lambion in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 08-27-2002, 09:10 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts