Displays status of jobs in the current session.
jobs [ -l | -n | -p ] [ JobID ... ]
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
|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).
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.
|-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
|>0||An error occurred.|
The screen displays a report similar to the following output:
+ 139 Running CC - C foo c& - 465 Stopped mail morris  687 Done(1) foo.bar&
job -p %m
Using the jobs reported in Example 1, the screen displays the following process ID:
|/usr/bin/ksh||Contains the Korn shell jobs built-in command.|
|/usr/bin/jobs||Contains the jobs command.|
The bg command,csh command, fg command, kill command, ksh command, wait command.