Main index

Introducing UNIX and Linux


Processes and devices

Overview
Processes
      Process status
      Foreground and background
      Process control
      Signals
Environment
      Environment variables
      Global and local variables
      Executable scripts
Program control
      Job control
      Command history list
      Running a job at a specific time
      Running programs periodically
      Big programs
      Timing a program
      Running programs in order
Quotes and escapes
Devices
Backquotes
Summary
Exercises

Foreground and background

When running a command interactively - that is, when you type in a command and wait for the system to respond - the command is being run in the foreground. You can instruct UNIX to run a program in the background instead. This means that the program will begin to run but you will be prompted by the shell for the next command without waiting for the program to complete - your login shell and the background program are effectively running simultaneously. In order to instruct UNIX to run a command in the background, follow the command with an ampersand (&) - try the following:

date &

A line will be printed confirming that the command has been sent to the background, and then you will be prompted for your next command with $. Meanwhile, date is executing, and shortly after its output is displayed you will be informed that date has completed running:

[1] 7293
$ Fri Dec 7 18:29:04 GMT 2001
[1]+ Exit 0 date


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck