1JOBS(1P)                   POSIX Programmer's Manual                  JOBS(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       jobs — display status of jobs in the current session
13

SYNOPSIS

15       jobs [-l|-p] [job_id...]
16

DESCRIPTION

18       The jobs utility shall display the status of jobs that were started  in
19       the  current shell environment; see Section 2.12, Shell Execution Envi‐
20       ronment.
21
22       When jobs reports the termination status of  a  job,  the  shell  shall
23       remove  its  process  ID  from the list of those ``known in the current
24       shell execution environment''; see Section 2.9.3.1, Examples.
25

OPTIONS

27       The jobs utility shall  conform  to  the  Base  Definitions  volume  of
28       POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
29
30       The following options shall be supported:
31
32       -l        (The  letter  ell.)  Provide  more information about each job
33                 listed. This information shall include the job  number,  cur‐
34                 rent  job,  process  group  ID,  state,  and the command that
35                 formed the job.
36
37       -p        Display only the process IDs for the process group leaders of
38                 the selected jobs.
39
40       By  default,  the  jobs utility shall display the status of all stopped
41       jobs, running background jobs and all jobs whose status has changed and
42       have not been reported by the shell.
43

OPERANDS

45       The following operand shall be supported:
46
47       job_id    Specifies  the  jobs for which the status is to be displayed.
48                 If no job_id is given, the status information  for  all  jobs
49                 shall  be displayed. The format of job_id is described in the
50                 Base Definitions volume of POSIX.1‐2017, Section  3.204,  Job
51                 Control Job ID.
52

STDIN

54       Not used.
55

INPUT FILES

57       None.
58

ENVIRONMENT VARIABLES

60       The following environment variables shall affect the execution of jobs:
61
62       LANG      Provide  a  default  value for the internationalization vari‐
63                 ables that are unset or null. (See the Base Definitions  vol‐
64                 ume  of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
65                 ables for the precedence  of  internationalization  variables
66                 used to determine the values of locale categories.)
67
68       LC_ALL    If  set  to  a non-empty string value, override the values of
69                 all the other internationalization variables.
70
71       LC_CTYPE  Determine the locale for the interpretation of  sequences  of
72                 bytes of text data as characters (for example, single-byte as
73                 opposed to multi-byte characters in arguments).
74
75       LC_MESSAGES
76                 Determine the locale that should be used to affect the format
77                 and contents of diagnostic messages written to standard error
78                 and informative messages written to standard output.
79
80       NLSPATH   Determine the location of message catalogs for the processing
81                 of LC_MESSAGES.
82

ASYNCHRONOUS EVENTS

84       Default.
85

STDOUT

87       If the -p option is specified, the output shall consist of one line for
88       each process ID:
89
90
91           "%d\n", <process ID>
92
93       Otherwise, if the -l option is not specified, the  output  shall  be  a
94       series of lines of the form:
95
96
97           "[%d] %c %s %s\n", <job-number>, <current>, <state>, <command>
98
99       where the fields shall be as follows:
100
101       <current> The  character '+' identifies the job that would be used as a
102                 default for the fg or bg utilities;  this  job  can  also  be
103                 specified  using  the  job_id  %+ or "%%".  The character '-'
104                 identifies the job that would become the default if the  cur‐
105                 rent default job were to exit; this job can also be specified
106                 using the job_id %-. For other jobs, this field is a <space>.
107                 At  most  one  job can be identified with '+' and at most one
108                 job can be identified with '-'.  If there  is  any  suspended
109                 job,  then the current job shall be a suspended job. If there
110                 are at least two suspended jobs, then the previous  job  also
111                 shall be a suspended job.
112
113       <job-number>
114                 A  number  that  can be used to identify the process group to
115                 the wait, fg, bg, and kill utilities. Using these  utilities,
116                 the  job  can  be identified by prefixing the job number with
117                 '%'.
118
119       <state>   One of the following strings (in the POSIX locale):
120
121                 Running   Indicates that the job has not been suspended by  a
122                           signal and has not exited.
123
124                 Done      Indicates  that the job completed and returned exit
125                           status zero.
126
127                 Done(code)
128                           Indicates that the job completed normally and  that
129                           it  exited with the specified non-zero exit status,
130                           code, expressed as a decimal number.
131
132                 Stopped   Indicates that the job was suspended by the SIGTSTP
133                           signal.
134
135                 Stopped (SIGTSTP)
136                           Indicates that the job was suspended by the SIGTSTP
137                           signal.
138
139                 Stopped (SIGSTOP)
140                           Indicates that the job was suspended by the SIGSTOP
141                           signal.
142
143                 Stopped (SIGTTIN)
144                           Indicates that the job was suspended by the SIGTTIN
145                           signal.
146
147                 Stopped (SIGTTOU)
148                           Indicates that the job was suspended by the SIGTTOU
149                           signal.
150
151                 The  implementation  may  substitute  the string Suspended in
152                 place of Stopped.  If the job was terminated by a signal, the
153                 format  of  <state>  is  unspecified, but it shall be visibly
154                 distinct from all of the other <state> formats shown here and
155                 shall  indicate the name or description of the signal causing
156                 the termination.
157
158       <command> The associated command that was given to the shell.
159
160       If the -l option is specified, a field containing the process group  ID
161       shall  be  inserted before the <state> field. Also, more processes in a
162       process group may be output on separate lines, using only  the  process
163       ID and <command> fields.
164

STDERR

166       The standard error shall be used only for diagnostic messages.
167

OUTPUT FILES

169       None.
170

EXTENDED DESCRIPTION

172       None.
173

EXIT STATUS

175       The following exit values shall be returned:
176
177        0    Successful completion.
178
179       >0    An error occurred.
180

CONSEQUENCES OF ERRORS

182       Default.
183
184       The following sections are informative.
185

APPLICATION USAGE

187       The -p option is the only portable way to find out the process group of
188       a job because different implementations have different  strategies  for
189       defining  the  process  group of the job. Usage such as $(jobs -p) pro‐
190       vides a way of referring to the process group of the job in  an  imple‐
191       mentation-independent way.
192
193       The  jobs utility does not work as expected when it is operating in its
194       own utility execution  environment  because  that  environment  has  no
195       applicable  jobs  to  manipulate. See the APPLICATION USAGE section for
196       bg.  For this reason, jobs is generally implemented as a shell  regular
197       built-in.
198

EXAMPLES

200       None.
201

RATIONALE

203       Both "%%" and "%+" are used to refer to the current job. Both forms are
204       of equal validity—the "%%" mirroring "$$" and "%+" mirroring the output
205       of  jobs.   Both forms reflect historical practice of the KornShell and
206       the C shell with job control.
207
208       The job control features provided by bg, fg, and jobs are based on  the
209       KornShell.  The standard developers examined the characteristics of the
210       C shell versions of these utilities and found that  differences  exist.
211       Despite  widespread  use  of  the  C shell, the KornShell versions were
212       selected for this volume of POSIX.1‐2017 to maintain a degree  of  uni‐
213       formity  with  the rest of the KornShell features selected (such as the
214       very popular command line editing features).
215
216       The jobs utility is not dependent on the job control option, as are the
217       seemingly  related bg and fg utilities because jobs is useful for exam‐
218       ining background jobs, regardless of the condition of job control. When
219       the  user  has invoked a set +m command and job control has been turned
220       off, jobs can still be used to examine the background  jobs  associated
221       with  that  current  session.  Similarly, kill can then be used to kill
222       background jobs with kill %<background job number>.
223
224       The output for terminated jobs is left unspecified to accommodate vari‐
225       ous historical systems. The following formats have been witnessed:
226
227        1. Killed(signal name)
228
229        2. signal name
230
231        3. signal name(coredump)
232
233        4. signal description- core dumped
234
235       Most  users  should  be  able  to understand these formats, although it
236       means that applications have trouble parsing them.
237
238       The calculation of job IDs was not described since this  would  suggest
239       an implementation, which may impose unnecessary restrictions.
240
241       In  an early proposal, a -n option was included to ``Display the status
242       of jobs that have changed, exited, or stopped  since  the  last  status
243       report''.  It  was  removed because the shell always writes any changed
244       status of jobs before each prompt.
245

FUTURE DIRECTIONS

247       None.
248

SEE ALSO

250       Section 2.12, Shell Execution Environment, bg, fg, kill, wait
251
252       The Base Definitions volume of POSIX.1‐2017, Section 3.204, Job Control
253       Job  ID, Chapter 8, Environment Variables, Section 12.2, Utility Syntax
254       Guidelines
255
257       Portions of this text are reprinted and reproduced in  electronic  form
258       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
259       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
260       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
261       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
262       event of any discrepancy between this version and the original IEEE and
263       The Open Group Standard, the original IEEE and The Open Group  Standard
264       is  the  referee document. The original Standard can be obtained online
265       at http://www.opengroup.org/unix/online.html .
266
267       Any typographical or formatting errors that appear  in  this  page  are
268       most likely to have been introduced during the conversion of the source
269       files to man page format. To report such errors,  see  https://www.ker
270       nel.org/doc/man-pages/reporting_bugs.html .
271
272
273
274IEEE/The Open Group                  2017                             JOBS(1P)
Impressum