ArticleslgStudy

science

Job control (Unix)

Job control (Unix) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Job control (Unix) rather than just read about it. In short: In a Unix or Unix-like operating system, job control refers to controlling a process group as a job via a shell. Control features include suspend, resume, and terminate, and more advanced features can be performed by sending a signal to a job.

Key takeaways

  • Job control (Unix) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Job control (Unix) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Job control (Unix) from memory before moving on to harder problems.

Reference excerpt

In a Unix or Unix-like operating system, job control refers to controlling a process group as a job via a shell. Control features include suspend, resume, and terminate, and more advanced features can be performed by sending a signal to a job. Job control allows a user to manage processing in the Unix-based multiprocessing environment, and is distinct from general computing job control. Job control was first implemented in the C shell by Jim Kulp, then at IIASA in Austria, making use of features of the 4.1BSD kernel. The KornShell, developed at Bell Labs, adopted it and it was later incorporated into the SVR4 version of the Bourne shell, and exists in most modern Unix shells.

Job A job encompasses all of the processes that start for the handling of a shell command line. A simple command line may start just one process, but a command line may result in multiple processes since a process can create child processes, and a command line can specify a pipeline of multiple commands. For example, the following command line selects lines containing the text "title", sorts them alphabetically, and displays the result in a terminal pager: grep title somefile.txt | sort | less. This creates at least three processes: one for grep, one for sort, and one for less. Job control allows the shell to control these processes as one entity.

Job ID A job is identified by a numeric job ID, a.k.a. job number which is classified as a handle since it is an abstract reference to a resource (a process group). An ID value, prefixed with %, can be used with a job control command to specify a job. The special references %% and %+ refer to the default job, the one that would be selected if none were specified. Bash documentation refers to a reference (starting with %) as a jobspec (short for job specification). Job control ID values are typically only used in an interactive shell. In scripting, PGID values are used instead, as they are more precise and robust, and indeed job control is disabled by default in a bash script.

Foreground/background By default, a job runs in the foreground where it uses interactive input and output. The user enters a command line and interacts with the processes but cannot issue another command until the current job terminates. Many operations (i.e. listing files) are relatively quick so the user can wait for a response with little down time and some operations (i.e. editing) require interaction that is only possible via a foreground job. But, if interaction is not required and the operation prevents access to the shell for a long time, the user may want to run it in the background – where the processes cannot access interactive input but the user can perform other foreground operations while the background job runs concurrently. By default background jobs output to the interactive output stream which results in the interleaving of output from the foreground and background jobs although a user may redirect output for a background job to prevent this.

Control POSIX specifies the user interface to job control – modeled on the Korn shell. The commands are typically implemented as shell builtins, not separate programs.

Start in background If a command line ends with &, then the job starts in the background. Pause foreground job The foreground job can be paused by pressing Ctrl+ Z. In this state, a job can be resumed in the background via bg or resumed in the foreground via fg. Command fg Command 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 Ctrl+ Z), then this command resumes that job. Command wait Command wait pauses the interactive session until the specified background jobs complete or for all background jobs of the active shell if none specified. Command bg Command bg (short for background) moves the paused foreground job to the background and resumes it. Command jobs Command jobs reports information about each background job including ID, command line and running status (stopped or running).

Signals

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Job control (Unix)

Start with the simplest possible case. Write down what Job control (Unix) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Job control (Unix) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Job control (Unix) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Job control (Unix)

In research
Job control (Unix) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Job control (Unix) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Job control (Unix) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Unix, so understanding it makes those chapters shorter.
In everyday life
Look for Job control (Unix) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Job control (Unix)” →

How to study Job control (Unix) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Job control (Unix) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Job control (Unix) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Job control (Unix) in simple terms?

In a Unix or Unix-like operating system, job control refers to controlling a process group as a job via a shell. Control features include suspend, resume, and terminate, and more advanced features can be performed by sending a signal to a job.

Why does Job control (Unix) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Job control (Unix)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Job control (Unix).

Tags

  • Unix

Keep exploring