Introduction to Unix and Shell Programming by M. G. Venkateshmurthy

Introduction to Unix and Shell Programming by M. G. Venkateshmurthy

Author:M. G. Venkateshmurthy [M. G. Venkateshmurthy]
Language: eng
Format: epub
Publisher: Pearson Education India
Published: 2005-05-01T16:00:00+00:00


7.4.1 Running a Command in the Background

A command is made to run in the background (as a background process) by terminating the command line with an ampersand (&) character as shown in the following example.

$sort –o student.lst student.lst &

567

$

The shell immediately returns the process identification (PID) number as well as the shell prompt $. In the above example, 567 is the PID of the just-submitted background job. As the shell prompt ($) re-appears immedietly, one can now readily work at the terminal.

One should be careful in running background processes as the user may get into problems under certain situations. Some of these problems could be due to any one of the following.

The success or failure of the background processes are not reported. The user has to find it out. For this purpose the identification number is used.

The output has to be redirected to a file as otherwise the display on the monitor gets mixed up.

Too many processes running in the background degrades the overall efficiency of the system.

There is a danger of the user logging out when some processes are still running in the background.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.