Job control (Unix): Difference between revisions

Content deleted Content added
Control: add anchors
 
Line 34:
 
; Start in background
:If a command line ends with {{code|&}}, then the job starts in the background.
 
; Pause foreground job
:The foreground job can be paused by pressing {{keypress |Ctrl| Z}}. In this state, a job can be resumed in the background via {{code |bg}} or resumed in the foreground via {{code |fg}}.
 
; Command {{code |fg}} {{anchor| fg}}
:Command {{code |fg}} (short for foreground) moves background job to the foreground; either the job specified or the one most recently added to the background if none specified. When the foreground job is paused (via {{keypress |Ctrl| Z}}), then this command resumes that job.
 
; Command {{code |wait}}
:Command [[wait (command)|<code>wait</code>]] pauses the interactive session until the specified background jobs complete or for all background jobs of the active shell if none specified.<ref>{{cite web | last=Kerrisk| first=Michael |date=Feb 2, 2025 |title=wait(1p) — Linux manual page |website=man7.org |url=https://www.man7.org/linux/man-pages/man1/wait.1p.html |publisher= |access-date=May 13, 2025}}</ref>
 
; Command {{code |bg}} {{anchor| bg}}
:Command {{code |bg}} (short for background) moves the paused foreground job to the background and resumes it.
 
; Command {{code |jobs}}
:Command {{code |jobs}} reports information about each background job including ID, command line and running status (stopped or running).
 
==Signals==