jobs

display the status of jobs in the current session

KornShell Built-in


SYNOPSIS

jobs [-lnp] [job-identifier...]


DESCRIPTION

jobs produces a list of the processes in the current session. Each such process is numbered for easy identification by the fg and kill commands and is described by a line of information:
[job-identifier]   default   state   shell_command
job-identifier

is a decimal number which identifies the process. When you use the job-identifier as an argument to the commands or to jobs, preface the number with %.

default

identifies the default process (that is, the most recently suspended process). If default is a +, this process is the default job. If default is a -, this job becomes the default when the current default job exits. There is at most one + job and one - job.

state

shows a job as:

Running
if it is not suspended and has not exited
Done
if it exited successfully
Done(exit status)
if it exited with a non-zero exit status
Stopped (signal)
if it is suspended; signal is the signal that suspended the job

shell_command

is the associated shell command which created the process.

Options

-l

also displays the process group ID of a job (before state).

-n

displays jobs that have changed states and free dead jobs.

-p

displays only the process IDs of all processes.

The -l and -p options are mutually exclusive.


DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

2

Failure due to an invalid command line argument.

jobs -k apple
jobs: Unknown option "-k"
> 0

The number of job-identifiers that were not found.

jobs %4
jobs: %4: No such job
echo $?
1


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0.

jobs is provided as a MKS KornShell built-in only.


NOTE

You cannot use | to pipe output from jobs to another command and get useful results. The jobs reports the status of background jobs in the current shell; however, when you use the pipe operator, jobs is actually run in a new shell, which does not have background jobs, so it cannot report on any. You can, however, use > to redirect jobs output to a file which can then be used as an input file by another command.


SEE ALSO

Commands:
kill, ps, wait


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]