|
|
In order to terminate a background job using a keyboard interrupt sequence, you must first move it into the foreground. To do this, use the fg(C) command followed by a ``%'' sign, then the PID, the command name, or the job number. For example, to move the find background process to the foreground, type the following:
$ jobs [2] + Running tar tv3 & [1] - Running find / -name README -print > logfile & $ fg %find find / -name README -print > logfileNote that the command line is returned, without the trailing ampersand. The following command line has the same effect:
$ fg %2 find / -name README -print > logfileThe process now executes in the foreground; that is, it takes control of the terminal, and will accept input typed at the keyboard, including interrupt sequences such as <Ctrl>Z.
fg entered without an argument, where only one background job exists, moves that job into the foreground. Where there are two or more background jobs, entering fg without an argument moves the job placed in the background most recently into the foreground.