Glossary

Job Control

Job control is the shell feature that lets you start and stop commands, move them between foreground and background, and see what is running. It is built on SIGSTOP, SIGCONT, SIGTTIN, and SIGTTOU signals, plus the kernel's concept of a process group and a controlling terminal.

long-command                    # runs in the foreground
Ctrl+Z                           # suspend it (SIGTSTP)
bg                              # resume it in the background
fg                              # bring it back to the foreground
long-command &                  # start directly in the background
jobs                            # list current jobs
fg %2                           # bring job 2 to foreground
kill %1                         # kill job 1
disown %1                        # remove from the job table

A backgrounded job continues running and can print to the terminal. If it tries to read from stdin while in the background, it is stopped with SIGTTIN until brought back to the foreground.

For long-running jobs that need to survive logout, the classic solution is nohup ... &, or better, running inside tmux or screen, which preserve the entire terminal session across disconnects. For system-level background work, use systemd services, which provide proper supervision.

Related terms: Signal, nohup, tmux

Discussed in:

Also defined in: Textbook of Linux