1JOBS(1P) POSIX Programmer's Manual JOBS(1P)
2
3
4
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
12 jobs - display status of jobs in the current session
13
15 jobs [-l| -p][job_id...]
16
18 The jobs utility shall display the status of jobs that were started in
19 the current shell environment; see Shell Execution Environment .
20
21 When jobs reports the termination status of a job, the shell shall
22 remove its process ID from the list of those "known in the current
23 shell execution environment''; see Asynchronous Lists .
24
26 The jobs utility shall conform to the Base Definitions volume of
27 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
28
29 The following options shall be supported:
30
31 -l (The letter ell.) Provide more information about each job
32 listed. This information shall include the job number, current
33 job, process group ID, state, and the command that formed the
34 job.
35
36 -p Display only the process IDs for the process group leaders of
37 the selected jobs.
38
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
45 The following operand shall be supported:
46
47 job_id Specifies the jobs for which the status is to be displayed. If
48 no job_id is given, the status information for all jobs shall be
49 displayed. The format of job_id is described in the Base Defini‐
50 tions volume of IEEE Std 1003.1-2001, Section 3.203, Job Control
51 Job ID.
52
53
55 Not used.
56
58 None.
59
61 The following environment variables shall affect the execution of jobs:
62
63 LANG Provide a default value for the internationalization variables
64 that are unset or null. (See the Base Definitions volume of
65 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
66 ables for the precedence of internationalization variables used
67 to determine the values of locale categories.)
68
69 LC_ALL If set to a non-empty string value, override the values of all
70 the other internationalization variables.
71
72 LC_CTYPE
73 Determine the locale for the interpretation of sequences of
74 bytes of text data as characters (for example, single-byte as
75 opposed to multi-byte characters in arguments).
76
77 LC_MESSAGES
78 Determine the locale that should be used to affect the format
79 and contents of diagnostic messages written to standard error
80 and informative messages written to standard output.
81
82 NLSPATH
83 Determine the location of message catalogs for the processing of
84 LC_MESSAGES .
85
86
88 Default.
89
91 If the -p option is specified, the output shall consist of one line for
92 each process ID:
93
94
95 "%d\n", <process ID>
96
97 Otherwise, if the -l option is not specified, the output shall be a
98 series of lines of the form:
99
100
101 "[%d] %c %s %s\n", <job-number>, <current>, <state>, <command>
102
103 where the fields shall be as follows:
104
105 <current>
106 The character '+' identifies the job that would be used as a
107 default for the fg or bg utilities; this job can also be speci‐
108 fied using the job_id %+ or "%%" . The character '-' identifies
109 the job that would become the default if the current default job
110 were to exit; this job can also be specified using the job_id
111 %-. For other jobs, this field is a <space>. At most one job can
112 be identified with '+' and at most one job can be identified
113 with '-' . If there is any suspended job, then the current job
114 shall be a suspended job. If there are at least two suspended
115 jobs, then the previous job also shall be a suspended job.
116
117 <job-number>
118 A number that can be used to identify the process group to the
119 wait, fg, bg, and kill utilities. Using these utilities, the job
120 can be identified by prefixing the job number with '%' .
121
122 <state>
123 One of the following strings (in the POSIX locale):
124
125 Running
126 Indicates that the job has not been suspended by a signal and
127 has not exited.
128
129 Done
130 Indicates that the job completed and returned exit status zero.
131
132 Done(code)
133 Indicates that the job completed normally and that it exited
134 with the specified non-zero exit status, code, expressed as a
135 decimal number.
136
137 Stopped
138 Indicates that the job was suspended by the SIGTSTP signal.
139
140 Stopped (SIGTSTP)
141
142 Indicates that the job was suspended by the SIGTSTP signal.
143
144 Stopped (SIGSTOP)
145
146 Indicates that the job was suspended by the SIGSTOP signal.
147
148 Stopped (SIGTTIN)
149
150 Indicates that the job was suspended by the SIGTTIN signal.
151
152 Stopped (SIGTTOU)
153
154 Indicates that the job was suspended by the SIGTTOU signal.
155
156
157 The implementation may substitute the string Suspended in place of
158 Stopped. If the job was terminated by a signal, the format of <state>
159 is unspecified, but it shall be visibly distinct from all of the other
160 <state> formats shown here and shall indicate the name or description
161 of the signal causing the termination.
162
163 <command>
164 The associated command that was given to the shell.
165
166
167 If the -l option is specified, a field containing the process group ID
168 shall be inserted before the <state> field. Also, more processes in a
169 process group may be output on separate lines, using only the process
170 ID and <command> fields.
171
173 The standard error shall be used only for diagnostic messages.
174
176 None.
177
179 None.
180
182 The following exit values shall be returned:
183
184 0 Successful completion.
185
186 >0 An error occurred.
187
188
190 Default.
191
192 The following sections are informative.
193
195 The -p option is the only portable way to find out the process group of
196 a job because different implementations have different strategies for
197 defining the process group of the job. Usage such as $( jobs -p) pro‐
198 vides a way of referring to the process group of the job in an imple‐
199 mentation-independent way.
200
201 The jobs utility does not work as expected when it is operating in its
202 own utility execution environment because that environment has no
203 applicable jobs to manipulate. See the APPLICATION USAGE section for bg
204 . For this reason, jobs is generally implemented as a shell regular
205 built-in.
206
208 None.
209
211 Both "%%" and "%+" are used to refer to the current job. Both forms
212 are of equal validity-the "%%" mirroring "$$" and "%+" mirroring the
213 output of jobs. Both forms reflect historical practice of the Korn‐
214 Shell and the C shell with job control.
215
216 The job control features provided by bg, fg, and jobs are based on the
217 KornShell. The standard developers examined the characteristics of the
218 C shell versions of these utilities and found that differences exist.
219 Despite widespread use of the C shell, the KornShell versions were
220 selected for this volume of IEEE Std 1003.1-2001 to maintain a degree
221 of uniformity with the rest of the KornShell features selected (such as
222 the very popular command line editing features).
223
224 The jobs utility is not dependent on the job control option, as are the
225 seemingly related bg and fg utilities because jobs is useful for exam‐
226 ining background jobs, regardless of the condition of job control.
227 When the user has invoked a set +m command and job control has been
228 turned off, jobs can still be used to examine the background jobs asso‐
229 ciated with that current session. Similarly, kill can then be used to
230 kill background jobs with kill% <background job number>.
231
232 The output for terminated jobs is left unspecified to accommodate vari‐
233 ous historical systems. The following formats have been witnessed:
234
235 1. Killed( signal name)
236
237 2. signal name
238
239 3. signal name( coredump)
240
241 4. signal description- core dumped
242
243 Most users should be able to understand these formats, although it
244 means that applications have trouble parsing them.
245
246 The calculation of job IDs was not described since this would suggest
247 an implementation, which may impose unnecessary restrictions.
248
249 In an early proposal, a -n option was included to "Display the status
250 of jobs that have changed, exited, or stopped since the last status
251 report". It was removed because the shell always writes any changed
252 status of jobs before each prompt.
253
255 None.
256
258 Shell Execution Environment, bg, fg, kill(), wait()
259
261 Portions of this text are reprinted and reproduced in electronic form
262 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
263 -- Portable Operating System Interface (POSIX), The Open Group Base
264 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
265 Electrical and Electronics Engineers, Inc and The Open Group. In the
266 event of any discrepancy between this version and the original IEEE and
267 The Open Group Standard, the original IEEE and The Open Group Standard
268 is the referee document. The original Standard can be obtained online
269 at http://www.opengroup.org/unix/online.html .
270
271
272
273IEEE/The Open Group 2003 JOBS(1P)