next up previous contents
Next: 2. System Startup and Up: 1.9 Processes Previous: 1.9 Processes   Contents

1.9.1 Background processes

The getty process (mingetty in the above example) is a ``foreground'' process, so called because it is in the foreground of your attention. Normally each command, or pipleline of commands is in the foreground. meaning they run, and you wait for them to return their results. It is also possible to execute programs as background processes. This means that you can execute the program, while still having your shell available for running other commands. The shell provides the & (ampersand) operator to allow you to run commands in the background. You simply add it to the end of a command line.

$ updatedb &

[1] 865

$
The command has not completed. It is still running, but you can use your system for other things while the backgrounded command proceeds. (updatedb updates the locate database.) When you run a command with the &, you get the shell prompt immediately and are able to enter further commands, even though the process you created is still running. The shell will return a process id (PID), so you can refer to that process, and then return your prompt for another command. Output will still come to your screen, because you did not redirect it. This can cause some confusion, since the output of the backgrounded process will be be mixed with the output of whatever command you are currently executing in the foreground.

Obviously the proper choice it to redirect the output of a background process to a file. You can also redirect the error output, so that it doesn't ``pop up'' on your screen.


next up previous contents
Next: 2. System Startup and Up: 1.9 Processes Previous: 1.9 Processes   Contents