Displays status of jobs in the current session.
The jobs command displays the status of jobs started in the current shell environment. If no specific job is specified with the JobID parameter, status information for all active jobs is displayed. If a job termination is reported, the shell removes that job's process ID from the list of those known by the current shell environment.
The /usr/bin/jobs command does not work when operating in its own command execution environment, because that environment does not have applicable jobs to manipulate. For this reason, the jobs command is implemented as a Korn shell or POSIX shell regular built-in command.
If the -p flag is specified, output consists of one line for each process ID. If no flags are specified, standard output is a series of lines with the following fields:
Item | Description |
---|---|
job-number | Indicates the process group number to use with the wait, fg, bg, and kill commands. When used with these commands, prefix the job number with a % (percent sign). |
current | A + (plus sign) identifies the job that will be used as a
default for the fg or bg commands. This job ID can also
be specified using the %+ (percent sign, plus) or %% (double
percent sign). A - (minus sign) identifies the job that becomes the default if the current default job exits. This job ID can also be specified using %- (percent sign, minus). For other jobs, the current field is a space character. Only one job can be identified with a +, and only one job can be identified with a -. If there is a single suspended job, that will be the current job. If there are at least two suspended jobs, then the previous job is also suspended. |
state | Displays one of the following values (in the POSIX locale):
|
command | The associated command that was given to the shell. |
If the -l flag is specified, a field containing the process group ID is inserted before the state field. Also, more processes in a process group may be output on separate lines, using only the job-number and command fields.
Item | Description |
---|---|
-l | (lowercase L) Provides more information about each job listed. This information includes the job number, current job, process group ID, state, and the command that initiated the job. |
-n | Displays only jobs that have stopped or exited since last notified. |
-p | Displays the process IDs for the process group leaders for the selected jobs. |
By default the jobs command displays the status of all stopped jobs, all running background jobs, and all jobs whose status has changed but not been reported by the shell.
The following exit values are returned:
Item | Description |
---|---|
0 | Successful completion. |
>0 | An error occurred. |
jobs -l
The screen displays a report
similar to the following output: +[4] 139 Running CC - C foo c&
-[3] 465 Stopped mail morris
[2] 687 Done(1) foo.bar&
jobs -p %m
Using the jobs reported
in Example 1, the screen displays the following process ID: 465
Item | Description |
---|---|
/usr/bin/ksh | Contains the Korn shell jobs built-in command. |
/usr/bin/jobs | Contains the jobs command. |