Previous | Table of Contents | Next |
DESCRIPTION
The internal bg command resumes stopped jobs by placing them in the background. The bg command is part of the job control feature of the C shell and the Korn shell. Without arguments, bg refers to the current job. The current job is the last job you stopped or suspended .
COMMAND FORMAT
Following is the general format of the bg command.
bg [ %job ... ]
Arguments
The following arguments may be passed to the bg command.
%job | A job number associated with a process. If the interactive option is on, job may be one of the following: | |
% num | A job number for an associated process. | |
% string | The job whose name begins with string. | |
%? string | The job whose name contains string. | |
%+ | ||
%% | Current job; the last process you stopped or suspended. | |
%- | Previous job; the process before the current job. |
RELATED COMMANDS
Refer to the fg , jobs , kill , and suspend commands described in modules 51, 68, 70, and 129.
APPLICATIONS
The bg command is used to restart suspended jobs in the background. You can suspend a job running in the background or one running in the foreground. This is handy if you are running a command and you need to perform some other function. For example, let s assume you are running a long process in background. You realize you need to create a file the process requires. You can suspend the job, create the file, then restart the process by using the bg command.
TYPICAL OPERATION
In this activity you use the bg command to restart a process in the background. Begin at the shell prompt. Before you start you may wish to check your suspend character, type stty -a or stty everything (BSD) and see to what character the suspend (susp) character is set.
cj> du -s > /dev/null ^Z [1] + Stopped du -s > /dev/null
cj> jobs [1] + Stopped du -s > /dev/null
cj> bg %1 [1]du -s > /dev/null
cj> kill %1 [1] + Terminated du -s > /dev/null
Previous | Table of Contents | Next |