Print this page
13507 some man pages need update following 13405
6308 some man pages are obsolete after moving to ksh builtins
   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    sh
  10        jobs [-p | -l] [% job_id...]
  11 
  12 
  13        jobs -x command [arguments]
  14 
  15 
  16        fg [% job_id...]
  17 
  18 
  19        bg [% job_id...]
  20 
  21 
  22        stop % job_id...
  23 
  24 
  25        stop pid...
  26 
  27 
  28    csh
  29        jobs [-l]
  30 
  31 
  32        fg [% job_id]
  33 
  34 
  35        bg [% job_id]...
  36 
  37 
  38        notify [% job_id]...
  39 
  40 
  41        stop % job_id...
  42 
  43 
  44        stop pid...
  45 
  46 
  47    ksh
  48        jobs [-lnp] [% job_id...]
  49 
  50 
  51        fg [% job_id...]
  52 
  53 
  54        bg [% job_id...]
  55 
  56 
  57        stop % job_id...
  58 
  59 
  60        stop pid...
  61 
  62 
  63    ksh93
  64        jobs [-lnp] [job_id...]
  65 
  66 
  67        fg [job_id...]
  68 
  69 
  70        bg [job_id...]
  71 
  72 
  73 DESCRIPTION
  74    sh
  75        When Job Control is enabled, the Bourne shell built-in jobs reports all
  76        jobs that are stopped or executing in the background. If %job_id is
  77        omitted, all jobs that are stopped or running in the background is
  78        reported.  The following options modify or enhance the output of jobs:
  79 
  80        -l
  81              Reports the process group ID and working directory of the jobs.
  82 
  83 
  84        -p
  85              Reports only the process group ID of the jobs.
  86 
  87 
  88        -x
  89              Replaces any job_id found in command or arguments with the
  90              corresponding process group ID, and then executes command passing
  91              it arguments.
  92 
  93 
  94 
  95        When the shell is invoked as jsh, Job Control is enabled in addition to
  96        all of the functionality described previously for sh. Typically Job
  97        Control is enabled for the interactive shell only. Non-interactive
  98        shells typically do not benefit from the added functionality of Job
  99        Control.
 100 
 101 
 102        With Job Control enabled every command or pipeline the user enters at
 103        the terminal is called a job_id. All jobs exist in one of the following
 104        states: foreground, background or stopped. These terms are defined as
 105        follows:
 106 
 107            1.     A job in the foreground has read and write access to the
 108                   controlling terminal.
 109 
 110            2.     A job in the background is denied read access and has
 111                   conditional write access to the controlling terminal (see
 112                   stty(1))
 113 
 114            3.     A stopped job is a job that has been placed in a suspended
 115                   state, usually as a result of a SIGTSTP signal (see
 116                   signal.h(3HEAD)).
 117 
 118 
 119        Every job that the shell starts is assigned a positive integer, called
 120        a job_id number which is tracked by the shell and are used as an
 121        identifier to indicate a specific job. Additionally, the shell keeps
 122        track of the current and previous jobs. The current job is the most
 123        recent job to be started or restarted. The previous job is the first
 124        non-current job.
 125 
 126 
 127        The acceptable syntax for a Job Identifier is of the form:
 128 
 129 
 130        %job_id
 131 
 132 
 133        where job_id can be specified in any of the following formats:
 134 
 135        % or +
 136                     for the current job
 137 
 138 
 139        -
 140                     for the previous job
 141 
 142 
 143        ?<string>
 144                     specify the job for which the command line uniquely
 145                     contains string.
 146 
 147 
 148        n
 149                     for job number n, where n is a job number
 150 
 151 
 152        pref
 153                     where pref is a unique prefix of the command name (for
 154                     example, if the command ls -l name were running in the
 155                     background, it could be referred to as %ls); pref cannot
 156                     contain blanks unless it is quoted.
 157 
 158 
 159 
 160        When Job Control is enabled, fg resumes the execution of a stopped job
 161        in the foreground, also moves an executing background job into the
 162        foreground. If %job_id is omitted the current job is assumed.
 163 
 164 
 165        When Job Control is enabled, bg resumes the execution of a stopped job
 166        in the background. If %job_id is omitted the current job is assumed.
 167 
 168 
 169        stop stops the execution of a background job(s) by using its job_id, or
 170        of any process by using its pid; see ps(1).
 171 
 172    csh
 173        The C shell built-in, jobs, without an argument, lists the active jobs
 174        under job control.
 175 
 176        -l
 177              List process IDs, in addition to the normal information.
 178 
 179 
 180 
 181        The shell associates a numbered job_id with each command sequence to
 182        keep track of those commands that are running in the background or have
 183        been stopped with TSTP signals (typically Control-Z). When a command or
 184        command sequence (semicolon-separated list) is started in the
 185        background using the & metacharacter, the shell displays     a line with
 186        the job number in brackets and a list of associated process numbers:
 187 
 188 
 189        [1] 1234
 190 
 191 


 226 
 227 
 228        A job running in the background stops when it attempts to read from the
 229        terminal. Background jobs can normally produce output, but this can be
 230        suppressed using the `stty tostop' command.
 231 
 232 
 233        fg brings the current or specified job_id into the foreground.
 234 
 235 
 236        bg runs the current or specified jobs in the background.
 237 
 238 
 239        stop stops the execution of a background job(s) by using its job_id, or
 240        of any process by using its pid; see ps(1).
 241 
 242 
 243        notify notifies the user asynchronously when the status of the current
 244        job or specified jobs changes.
 245 
 246    ksh
 247        jobs displays the status of the jobs that were started in the current
 248        shell environment. When jobs reports the termination status of a job,
 249        the shell removes its process ID from the list of those known in the
 250        current shell execution environment.
 251 
 252 
 253        job_id specifies the jobs for which the status is to be displayed. If
 254        no job_id is specified, the status information for all jobs are
 255        displayed.
 256 
 257 
 258        The following options modify or enhance the output of jobs:
 259 
 260        -l
 261              (The letter ell.) Provides more information about each job
 262              listed. This information includes the job number, current job,
 263              process group ID, state and the command that formed the job.
 264 
 265 
 266        -n
 267              Displays only jobs that have stopped or exited since last
 268              notified.
 269 
 270 
 271        -p
 272              Displays only the process IDs for the process group leaders of
 273              the selected jobs.
 274 
 275 
 276 
 277        By default, jobs displays the status of all the stopped jobs, running
 278        background jobs, and all jobs whose status has changed and have not
 279        been reported by the shell.
 280 
 281 
 282        If the monitor option of the set command is turned on, an interactive
 283        shell associates a job with each pipeline. It keeps a table of current
 284        jobs, printed by the jobs command, and assigns them small integer
 285        numbers. When a job is started asynchronously with &, the shell prints
 286        a line which looks like:
 287 
 288 
 289        [1] 1234
 290 
 291 
 292        indicating that the job, which was started asynchronously, was job
 293        number 1 and had one (top-level) process, whose process id was 1234.
 294 
 295 
 296        If you are running a job and wish to do something else you can hit the
 297        key ^Z (Control-Z) which sends a STOP signal to the current job. The
 298        shell then normally indicates that the job has been "Stopped" (see
 299        OUTPUT below), and print another prompt. You can then manipulate the
 300        state of this job, putting it in the background with the bg command, or
 301        run some other commands and then eventually bring the job back into the
 302        foreground with the foreground command fg. A ^Z takes effect
 303        immediately and is like an interrupt, in that pending output and unread
 304        input are discarded when it is typed.
 305 
 306 
 307        There are several ways to refer to jobs in the shell. A job can be
 308        referred to by the process id of any process of the job or by one of
 309        the following:
 310 
 311        %number
 312                    The job with the specified number.
 313 
 314 
 315        %string
 316                    Any job whose command line begins with string; works only
 317                    in the interactive mode when the history file is active.
 318 
 319 
 320        %?string
 321                    Any job whose command line contains string; works only in
 322                    the interactive mode when the history file is active.
 323 
 324 
 325        %%
 326                    Current job.
 327 
 328 
 329        %+
 330                    Equivalent to %%.
 331 
 332 
 333        %-
 334                    Previous job.
 335 
 336 
 337 
 338        The shell learns immediately whenever a process changes state. It
 339        normally informs you whenever a job becomes blocked so that no further
 340        progress is possible, but only just before it prints a prompt. This is
 341        done so that it does not otherwise disturb your work. When the monitor
 342        mode is on, each background job that completes triggers any trap set
 343        for CHLD. When you try to leave the shell while jobs are running or
 344        stopped, you are warned that `You have stopped (running) jobs.' You can
 345        use the jobs command to see what they are. If you do this or
 346        immediately try to exit again, the shell does not warn you a second
 347        time, and the stopped jobs are terminated.
 348 
 349 
 350        fg moves a background job from the current environment into the
 351        foreground. Using fg to place a job in the foreground removes its
 352        process ID from the list of those known in the current shell execution
 353        environment. The fg command is available only on systems that support
 354        job control. If job_id is not specified, the current job is brought
 355        into the foreground.
 356 
 357 
 358        bg resumes suspended jobs from the current environment by running them
 359        as background jobs. If the job specified by job_id is already a running
 360        background job, bg has no effect and exits successfully. Using bg to
 361        place a job into the background causes its process ID to become `known
 362        in the current shell execution environment, as if it had been started
 363        as an asynchronous list. The bg command is available only on systems
 364        that support job control. If job_id is not specified, the current job
 365        is placed in the background.
 366 
 367 
 368        stop stops the execution of a background job(s) by using its job_id, or
 369        of any process by using its pid. See ps(1).
 370 
 371    ksh93
 372        jobs displays information about specified jobs that were started by the
 373        current shell environment on standard output. The information contains
 374        the job number enclosed in [...], the status, and the command line that
 375        started the job.
 376 
 377 
 378        If job_id is omitted, jobs displays the status of all stopped jobs,
 379        background jobs, and all jobs whose status has changed since last
 380        reported by the shell.
 381 
 382 
 383        When jobs reports the termination status of a job, the shell removes
 384        the job from the list of known jobs in the current shell environment.
 385 
 386 
 387        The following options modify or enhances the output of jobs:
 388 
 389        -l
 390              Displays process IDs after the job number in addition to the


 533                      and indicates the name or description of the signal
 534                      causing the termination.
 535 
 536 
 537        command
 538                      The associated command that was specified to the shell.
 539 
 540 
 541 
 542        If the -l option is specified, a field containing the process group ID
 543        is inserted before the state field. Also, more processes in a process
 544        group can be output on separate lines, using only the process ID and
 545        command fields.
 546 
 547 ENVIRONMENT VARIABLES
 548        See environ(5) for descriptions of the following environment variables
 549        that affect the execution of jobs, fg, and bg: LANG, LC_ALL, LC_CTYPE,
 550        LC_MESSAGES, and NLSPATH.
 551 
 552 EXIT STATUS
 553    sh, csh, ksh
 554        The following exit values are returned for jobs, fg, and bg:
 555 
 556        0
 557              Successful completion.
 558 
 559 
 560        >0
 561              An error occurred.
 562 
 563 
 564    ksh93
 565        The following exit values are returned for jobs:
 566 
 567        0
 568              The information for each job is written to standard output.
 569 
 570 
 571        >0
 572              One or more jobs does not exist.
 573 


 582 
 583        non-zero
 584                                   One or more jobs does not exist or has
 585                                   completed.
 586 
 587 
 588 
 589        The following exit values are returned for bg:
 590 
 591        0
 592              All background jobs are started.
 593 
 594 
 595        >0
 596              One more jobs does not exist or there are no background jobs.
 597 
 598 
 599 ATTRIBUTES
 600        See attributes(5) for descriptions of the following attributes:
 601 
 602    csh, sh, ksh
 603 
 604 
 605 
 606        +--------------------+-------------------+
 607        |  ATTRIBUTE TYPE    |  ATTRIBUTE VALUE  |
 608        +--------------------+-------------------+
 609        |Interface Stability | Committed         |
 610        +--------------------+-------------------+
 611        |Standard            | See standards(5). |
 612        +--------------------+-------------------+
 613 
 614    ksh93
 615 
 616 
 617 
 618        +--------------------+-----------------+
 619        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 620        +--------------------+-----------------+
 621        |Interface Stability | Uncommitted     |
 622        +--------------------+-----------------+
 623 
 624 SEE ALSO
 625        csh(1), kill(1), ksh(1), ksh93(1), ps(1), sh(1), stop(1),
 626        shell_builtins(1), stty(1), wait(1), signal.h(3HEAD), attributes(5),
 627        environ(5), standards(5)
 628 
 629 
 630 
 631                                November 2, 2007                        JOBS(1)
   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 


  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


 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 


 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)