1 JOBS(1)                          User Commands                         JOBS(1)
   2 
   3 
   4 
   5 NAME
   6        jobs, fg, bg, stop, notify - control process execution
   7 
   8 SYNOPSIS
   9    csh
  10        jobs [-l]
  11 
  12 
  13        fg [% job_id]
  14 
  15 
  16        bg [% job_id]...
  17 
  18 
  19        notify [% job_id]...
  20 
  21 
  22        stop % job_id...
  23 
  24 
  25        stop pid...
  26 
  27 
  28    ksh93
  29        jobs [-lnp] [job_id...]
  30 
  31 
  32        fg [job_id...]
  33 
  34 
  35        bg [job_id...]
  36 
  37 
  38 DESCRIPTION
  39    csh
  40        The C shell built-in, jobs, without an argument, lists the active jobs
  41        under job control.
  42 
  43        -l
  44              List process IDs, in addition to the normal information.
  45 
  46 
  47 
  48        The shell associates a numbered job_id with each command sequence to
  49        keep track of those commands that are running in the background or have
  50        been stopped with TSTP signals (typically Control-Z). When a command or
  51        command sequence (semicolon-separated list) is started in the
  52        background using the & metacharacter, the shell displays     a line with
  53        the job number in brackets and a list of associated process numbers:
  54 
  55 
  56        [1] 1234
  57 
  58 
  59        To see the current list of jobs, use the jobs built-in command. The job
  60        most recently stopped (or put into the background if none are stopped)
  61        is referred to as the current job and is indicated with a `+'. The
  62        previous job is indicated with a `-'; when the current job is
  63        terminated or moved to the foreground, this job takes its place
  64        (becomes the new current job).
  65 
  66 
  67        To manipulate jobs, refer to the bg, fg, kill, stop, and % built-in
  68        commands.
  69 
  70 
  71        A reference to a job begins with a `%'. By itself, the percent sign
  72        refers to the current job.
  73 
  74        % %+ %%
  75                    The current job.
  76 
  77 
  78        %-
  79                    The previous job.
  80 
  81 
  82        %j
  83                    Refer to job j as in: `kill -9 %j'. j can be a job number,
  84                    or a string that uniquely specifies the command line by
  85                    which it was started; `fg %vi' might bring a stopped vi job
  86                    to the foreground, for instance.
  87 
  88 
  89        %?string
  90                    Specify the job for which the command line uniquely
  91                    contains string.
  92 
  93 
  94 
  95        A job running in the background stops when it attempts to read from the
  96        terminal. Background jobs can normally produce output, but this can be
  97        suppressed using the `stty tostop' command.
  98 
  99 
 100        fg brings the current or specified job_id into the foreground.
 101 
 102 
 103        bg runs the current or specified jobs in the background.
 104 
 105 
 106        stop stops the execution of a background job(s) by using its job_id, or
 107        of any process by using its pid; see ps(1).
 108 
 109 
 110        notify notifies the user asynchronously when the status of the current
 111        job or specified jobs changes.
 112 
 113    ksh93
 114        jobs displays information about specified jobs that were started by the
 115        current shell environment on standard output. The information contains
 116        the job number enclosed in [...], the status, and the command line that
 117        started the job.
 118 
 119 
 120        If job_id is omitted, jobs displays the status of all stopped jobs,
 121        background jobs, and all jobs whose status has changed since last
 122        reported by the shell.
 123 
 124 
 125        When jobs reports the termination status of a job, the shell removes
 126        the job from the list of known jobs in the current shell environment.
 127 
 128 
 129        The following options modify or enhances the output of jobs:
 130 
 131        -l
 132              Displays process IDs after the job number in addition to the
 133              usual information.
 134 
 135 
 136        -n
 137              Displays only the jobs whose status has changed since the last
 138              prompt was displayed.
 139 
 140 
 141        -p
 142              Displays the process group leader IDs for the specified jobs.
 143 
 144 
 145 
 146        job_id can be specified to jobs, fg, and bg as one of the following:
 147 
 148        number
 149                    The process id of job.
 150 
 151 
 152        -number
 153                    The process group id of job.
 154 
 155 
 156        %number
 157                    The job number.
 158 
 159 
 160        %string
 161                    The job whose name begins with string.
 162 
 163 
 164        %?string
 165                    The job whose name contains string.
 166 
 167 
 168        %+
 169        %%
 170                    The current job.
 171 
 172 
 173        %-
 174                    The previous job.
 175 
 176 
 177 
 178        fg places the specified jobs into the foreground in sequence and sends
 179        a CONT signal to start each running. If job_id is omitted, the most
 180        recently started or stopped background job is moved to the foreground.
 181 
 182 
 183        bg places the specified jobs into the background and sends a CONT
 184        signal to start them running. If job_id is omitted, the most recently
 185        started or stopped background job is resumed or continued in the
 186        background.
 187 
 188 OUTPUT
 189        If the -p option is specified, the output consists of one line for each
 190        process ID:
 191 
 192 
 193        "%d\n", "process ID"
 194 
 195 
 196        Otherwise, if the -l option is not specified, the output is a series of
 197        lines of the form:
 198 
 199 
 200        "[%d] %c %s %s\n", job-number, current, state, command
 201 
 202 
 203        where the fields are as follows:
 204 
 205        current
 206                      The character + identifies the job that would be used as
 207                      a default for the fg or bg commands. This job can also be
 208                      specified using the job_id %+ or %% . The character -
 209                      identifies the job that would become the default if the
 210                      current default job were to exit; this job can also be
 211                      specified using the job_id %- . For other jobs, this
 212                      field is a space character. At most, one job can be
 213                      identified with + and at most one job can be identified
 214                      with -. If there is any suspended job, then the current
 215                      job is a suspended job. If there are at least two
 216                      suspended jobs, then the previous job is also a suspended
 217                      job.
 218 
 219 
 220        job-number
 221                      A number that can be used to identify the process group
 222                      to the wait, fg, bg, and kill utilities. Using these
 223                      utilities, the job can be identified by prefixing the job
 224                      number with %.
 225 
 226 
 227        state
 228                      One of the following strings in the POSIX Locale:
 229 
 230                      Running
 231                                          Indicates that the job has not been
 232                                          suspended by a signal and has not
 233                                          exited.
 234 
 235 
 236                      Done
 237                                          Indicates that the job completed and
 238                                          returned exit status zero.
 239 
 240 
 241                      Done(code)
 242                                          Indicates that the job completed
 243                                          normally and that it exited with the
 244                                          specified non-zero exit status, code,
 245                                          expressed as a decimal number.
 246 
 247 
 248                      Stopped
 249                                          Indicates that the job was stopped.
 250 
 251 
 252                      Stopped(SIGTSTP)
 253                                          Indicates that the job was suspended
 254                                          by the SIGTSTP signal.
 255 
 256 
 257                      Stopped(SIGSTOP)
 258                                          Indicates that the job was suspended
 259                                          by the SIGSTOP signal.
 260 
 261 
 262                      Stopped(SIGTTIN)
 263                                          Indicates that the job was suspended
 264                                          by the SIGTTIN signal.
 265 
 266 
 267                      Stopped(SIGTTOU)
 268                                          Indicates that the job was suspended
 269                                          by the SIGTTOU signal.
 270 
 271                      The implementation can substitute the string Suspended in
 272                      place of Stopped. If the job was terminated by a signal,
 273                      the format of state is unspecified, but it is visibly
 274                      distinct from all of the other state formats shown here
 275                      and indicates the name or description of the signal
 276                      causing the termination.
 277 
 278 
 279        command
 280                      The associated command that was specified to the shell.
 281 
 282 
 283 
 284        If the -l option is specified, a field containing the process group ID
 285        is inserted before the state field. Also, more processes in a process
 286        group can be output on separate lines, using only the process ID and
 287        command fields.
 288 
 289 ENVIRONMENT VARIABLES
 290        See environ(5) for descriptions of the following environment variables
 291        that affect the execution of jobs, fg, and bg: LANG, LC_ALL, LC_CTYPE,
 292        LC_MESSAGES, and NLSPATH.
 293 
 294 EXIT STATUS
 295    csh
 296        The following exit values are returned for jobs, fg, and bg:
 297 
 298        0
 299              Successful completion.
 300 
 301 
 302        >0
 303              An error occurred.
 304 
 305 
 306    ksh93
 307        The following exit values are returned for jobs:
 308 
 309        0
 310              The information for each job is written to standard output.
 311 
 312 
 313        >0
 314              One or more jobs does not exist.
 315 
 316 
 317 
 318        The following exit values are returned for fg:
 319 
 320        exit status of last job
 321                                   One or more jobs has been brought into the
 322                                   foreground.
 323 
 324 
 325        non-zero
 326                                   One or more jobs does not exist or has
 327                                   completed.
 328 
 329 
 330 
 331        The following exit values are returned for bg:
 332 
 333        0
 334              All background jobs are started.
 335 
 336 
 337        >0
 338              One more jobs does not exist or there are no background jobs.
 339 
 340 
 341 ATTRIBUTES
 342        See attributes(5) for descriptions of the following attributes:
 343 
 344    csh
 345 
 346        +--------------------+-------------------+
 347        |  ATTRIBUTE TYPE    |  ATTRIBUTE VALUE  |
 348        +--------------------+-------------------+
 349        |Interface Stability | Committed         |
 350        +--------------------+-------------------+
 351        |Standard            | See standards(5). |
 352        +--------------------+-------------------+
 353 
 354    ksh93
 355 
 356        +--------------------+-----------------+
 357        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 358        +--------------------+-----------------+
 359        |Interface Stability | Uncommitted     |
 360        +--------------------+-----------------+
 361 
 362 SEE ALSO
 363        csh(1), kill(1), ksh93(1), ps(1), stop(1), shell_builtins(1), stty(1),
 364        wait(1), signal.h(3HEAD), attributes(5), environ(5), standards(5)
 365 
 366 
 367 
 368                                February 9, 2021                        JOBS(1)