Bash Shell Scripting
Crash Course
crowfly.net

<<   >>

Introduction

GNU_Tools

Example1

Example2

Execution_bit

Bang_bin_bash

Example3

The_dot

Example4

Example5

Example6

Example7

Example8

Background

Forking

Example9

Bash_profile

Pattern_match

Regex

Debug

Gory_details

References

<<   >>
Background processing

If you want to run a process in the background simply put an ampersand (&) on the end of the line.

  dlink@viddev1> find / -name "*bojangles*"> $HOME/bojangles.lst 2>/dev/null &
  [3] 6569

To see what's going on you can use jobs:

  dlink@viddev1> jobs
  [2]-  Running  emacs -T "E $HOSTNAME" . &
  [3]+  Running  find / -name "bojangles">$HOME/bojangles.lst 2>/dev/null 

What if you ran something in the foreground but really wanted to run it in the background?:

  dlink@viddev1> xclock -update 1
  []

xclock fires up, assuming you are in X Windows.

Now the cursor is just sitting there - You can no longer use this shell to enter more commands.

Bummer

1.) You can quit xclock and the shell will resume, or

2.) You can break out of it with CTRL-c. This kills xclock and the shell will resume, or

3.) You can suspend xclock with CTRL-z. Then send it into the background with bg. Xclock continues to run and the shell will resume:

  dlink@viddev1> xclock -update 1
  CTRL-z
  [4]+  Stopped                 xclock -update 1
  dlink@viddev1> bg
  [4]+ xclock -update 1 &
  dlink@viddev1> 

You can bring it back to the foreground again with fg:

  dlink@viddev1> fg
  xclock -update 1