Runs jobs in the background.
bg [ JobID ... ]
If job control is enabled (see "Job Control in the Korn shell or POSIX shell" in AIX® Version 7.1 Operating system and device management), the bg command resumes suspended jobs in the current environment by running them as background jobs. If the specified job is already running in the background, the bg command has no effect and exits successfully. If no JobID parameter is supplied, the bg command uses the most recently suspended job.
The JobID parameter can be a process ID number, or you can use one of the following symbol combinations:
Item | Description |
---|---|
%Number | Refers to a job by the job number. |
%String | Refers to a job whose name begins with the specified string. |
%?String | Refers to a job whose name contains the specified string. |
%+ OR %% | Refers to the current job. |
%- | Refers to the previous job. |
Using the bg command to place a job into the background causes the job's process ID to become known in the current shell environment. The bg command output displays the job number and the command associated with that job. The job number can be used with the wait, fg, and kill commands by prefixing the job number with a % (percent sign). For example, kill %3.
stty tostop
kill -s stop JobID
Command | xargs bg
Each /usr/bin/bg command operates in a different environment and does not share the parent shell's understanding of jobs. For this reason, the bg command is implemented as a Korn shell or POSIX shell regular built-in.
The following exit values are returned:
Item | Description |
---|---|
0 | Successful completion. |
>0 | An error occurred. |
If job control is disabled, the bg command exits with an error, and no job is placed in the background.
[2] + Stopped (SIGSTOP) sleep 100 &
use the job number to resume the sleep 100 & job by entering:
bg %2
The screen displays the revised status of job 2:
[2] sleep 100 &
Item | Description |
---|---|
/usr/bin/ksh | Contains the Korn shell bg built-in command. |
/usr/bin/bg | Contains the bg command. |