1BG(1P)                     POSIX Programmer's Manual                    BG(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       bg — run jobs in the background
13

SYNOPSIS

15       bg [job_id...]
16

DESCRIPTION

18       If job control is enabled (see the description of set -m), the bg util‐
19       ity  shall resume suspended jobs from the current environment (see Sec‐
20       tion 2.12, Shell Execution Environment) by running them  as  background
21       jobs.  If  the  job specified by job_id is already a running background
22       job, the bg utility shall have no effect and shall exit successfully.
23
24       Using bg to place a job into the background shall cause its process  ID
25       to  become  ``known in the current shell execution environment'', as if
26       it had been started as an asynchronous list; see Section 2.9.3.1, Exam‐
27       ples.
28

OPTIONS

30       None.
31

OPERANDS

33       The following operand shall be supported:
34
35       job_id    Specify  the  job  to  be  resumed as a background job. If no
36                 job_id operand is given,  the  most  recently  suspended  job
37                 shall  be used. The format of job_id is described in the Base
38                 Definitions volume of POSIX.1‐2017, Section 3.204,  Job  Con‐
39                 trol Job ID.
40

STDIN

42       Not used.
43

INPUT FILES

45       None.
46

ENVIRONMENT VARIABLES

48       The following environment variables shall affect the execution of bg:
49
50       LANG      Provide  a  default  value for the internationalization vari‐
51                 ables that are unset or null. (See the Base Definitions  vol‐
52                 ume  of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
53                 ables for the precedence  of  internationalization  variables
54                 used to determine the values of locale categories.)
55
56       LC_ALL    If  set  to  a non-empty string value, override the values of
57                 all the other internationalization variables.
58
59       LC_CTYPE  Determine the locale for the interpretation of  sequences  of
60                 bytes of text data as characters (for example, single-byte as
61                 opposed to multi-byte characters in arguments).
62
63       LC_MESSAGES
64                 Determine the locale that should be used to affect the format
65                 and  contents  of  diagnostic  messages  written  to standard
66                 error.
67
68       NLSPATH   Determine the location of message catalogs for the processing
69                 of LC_MESSAGES.
70

ASYNCHRONOUS EVENTS

72       Default.
73

STDOUT

75       The output of bg shall consist of a line in the format:
76
77
78           "[%d] %s\n", <job-number>, <command>
79
80       where the fields are as follows:
81
82       <job-number>
83                 A  number  that  can be used to identify the job to the wait,
84                 fg, and kill utilities. Using these utilities, the job can be
85                 identified by prefixing the job number with '%'.
86
87       <command> The associated command that was given to the shell.
88

STDERR

90       The standard error shall be used only for diagnostic messages.
91

OUTPUT FILES

93       None.
94

EXTENDED DESCRIPTION

96       None.
97

EXIT STATUS

99       The following exit values shall be returned:
100
101        0    Successful completion.
102
103       >0    An error occurred.
104

CONSEQUENCES OF ERRORS

106       If job control is disabled, the bg utility shall exit with an error and
107       no job shall be placed in the background.
108
109       The following sections are informative.
110

APPLICATION USAGE

112       A job is generally suspended by typing the SUSP character  (<control>‐Z
113       on  most  systems);  see  the  Base Definitions volume of POSIX.1‐2017,
114       Chapter 11, General Terminal Interface.  At that point, bg can put  the
115       job into the background. This is most effective when the job is expect‐
116       ing no terminal input and its output has been redirected to  non-termi‐
117       nal  files. A background job can be forced to stop when it has terminal
118       output by issuing the command:
119
120
121           stty tostop
122
123       A background job can be stopped with the command:
124
125
126           kill -s stop job ID
127
128       The bg utility does not work as expected when it is  operating  in  its
129       own  utility execution environment because that environment has no sus‐
130       pended jobs. In the following examples:
131
132
133           ... | xargs bg
134           (bg)
135
136       each bg operates in a different environment and does not share its par‐
137       ent  shell's  understanding  of  jobs. For this reason, bg is generally
138       implemented as a shell regular built-in.
139

EXAMPLES

141       None.
142

RATIONALE

144       The extensions to the shell specified in this  volume  of  POSIX.1‐2017
145       have  mostly  been based on features provided by the KornShell. The job
146       control features provided by bg, fg, and jobs are  also  based  on  the
147       KornShell.  The standard developers examined the characteristics of the
148       C shell versions of these utilities and found that  differences  exist.
149       Despite  widespread  use  of  the  C shell, the KornShell versions were
150       selected for this volume of POSIX.1‐2017 to maintain a degree  of  uni‐
151       formity  with  the rest of the KornShell features selected (such as the
152       very popular command line editing features).
153
154       The bg utility is expected to wrap its output if the output exceeds the
155       number of display columns.
156

FUTURE DIRECTIONS

158       None.
159

SEE ALSO

161       Section 2.9.3.1, Examples, fg, kill, jobs, wait
162
163       The Base Definitions volume of POSIX.1‐2017, Section 3.204, Job Control
164       Job ID, Chapter 8, Environment Variables, Chapter 11, General  Terminal
165       Interface
166
168       Portions  of  this text are reprinted and reproduced in electronic form
169       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
170       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
171       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
172       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
173       event of any discrepancy between this version and the original IEEE and
174       The  Open Group Standard, the original IEEE and The Open Group Standard
175       is the referee document. The original Standard can be  obtained  online
176       at http://www.opengroup.org/unix/online.html .
177
178       Any  typographical  or  formatting  errors that appear in this page are
179       most likely to have been introduced during the conversion of the source
180       files  to  man page format. To report such errors, see https://www.ker
181       nel.org/doc/man-pages/reporting_bugs.html .
182
183
184
185IEEE/The Open Group                  2017                               BG(1P)
Impressum