Results 1 to 5 of 5

Thread: Send process to background using &

  1. #1
    Join Date
    Sep 2010
    Beans
    51

    Send process to background using &

    Hi,

    I'm running this command in the background:

    grep -r "word" &

    Now, when I type in "jobs" I get this:
    [1]+ Stopped grep -r "word"

    Why it stopped? I run then "fg" and comes up fine. But if I leave it there it won't run at all

    Help!

  2. #2
    Join Date
    Jul 2005
    Location
    England
    Beans
    Hidden!

    Re: Send process to background using &

    Try using & disown after the command and it should work fine.

    There is no man page in ubuntu for disown, but you can find out about it from
    Code:
    man bash | less +/"^ +disown"
    or even
    Code:
    help disown
    in terminal as it is a built-in bash shell command.
    DISTRO: Xubuntu 14.04-64bit --- Code-tags --- Boot-Repair --- Grub2 wiki & Grub2 Basics --- RootSudo

  3. #3
    Join Date
    Apr 2006
    Location
    Ubuntuland
    Beans
    2,124
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Send process to background using &

    Since you didn't give it a filename, its waiting for input from stdin (i.e., the keyboard). Since its in the background there is no keyboard.
    24 beers in a case, 24 hours in a day. Coincidence? I think not!

    Trusty Tahr 64 bit, AMD Phenom II 955 Quad Core 3.2GHz, GeForce 9600 GT
    16G PC2-6400 RAM, 128 GB SSD, Twin 1TB SATA 7200 RPM RAID0

  4. #4
    Join Date
    Sep 2010
    Beans
    51

    Re: Send process to background using &

    Quote Originally Posted by Slim Odds View Post
    Since you didn't give it a filename, its waiting for input from stdin (i.e., the keyboard). Since its in the background there is no keyboard.
    Thanks, so I could run something like this?:
    grep -r "word">results.txt &

  5. #5
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Send process to background using &

    grep searches files or data streams for patterns. in your case you search for word recursively (in the current directory and below). But you have not entered any file name. And you should not redirect the output to where you search, so I suggest something like this

    Code:
    grep -r "word" *.txt > /tmp/results.txt &
    to search for word in txt-files in the current directory and below.

Bookmarks

Posting Permissions

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