Loading...

Lab 44: Process Management

Control system responsiveness by moving jobs between the foreground and background, and by lowering CPU priority with nice. Validate your job state and apply priority changes in a controlled, operator-safe way.

troubleshooting core services

Scenario

The server feels sluggish during routine work, and you suspect a combination of interactive shells and CPU-heavy commands are competing for resources. You need to manage job state (foreground vs background) and reduce the priority of a noisy workload so the system stays usable while it runs.

Operator context

Job control keeps you productive in a live shell session. Priority control helps you be a good citizen on shared systems without killing workloads that still need to finish.

Objective

  • Launch a long-running job in the background and confirm it is running.
  • Bring a background job to the foreground and suspend it safely.
  • Resume a suspended job in the background and confirm job state.
  • Start a CPU-heavy workload with reduced priority using nice .

What You’ll Practice

  • Background execution using & and tracking job IDs.
  • Inspecting job state using jobs .
  • Moving jobs between foreground/background with fg and bg .
  • Suspending foreground work with Ctrl+Z .
  • Reducing CPU priority at start time using nice -n .

Walkthrough

Step 1 : Launch a long-running job in the background.
Command
sleep 60 &

Appending & starts the command in the background and returns you to the prompt. This is useful for long-running commands that do not need your immediate attention.

Job [1] 1234 running in background.
Step 2 : View background jobs.
Command
jobs

jobs reports tasks the current shell is tracking. This is job control scope, not a full system process list.

[1]+  Running                 sleep 60 &
Step 3 : Bring the job to the foreground and suspend it.
Command
fg %1

fg attaches the job to your terminal again. To pause it without killing it, you can press Ctrl+Z which sends a stop signal and returns control to your shell.

sleep 60

(user presses Ctrl+Z to suspend it)
[1]+  Stopped                 sleep 60
Step 4 : Resume the job in the background.
Command
bg %1

bg continues a stopped job but keeps it in the background. This is a clean way to let work finish while you keep using the terminal.

[1]+ sleep 60 &
Step 5 : Launch a CPU-heavy task with reduced priority.
Safety note

yes will generate endless output. Redirect to /dev/null as shown, and treat this like a test workload you should stop after confirming behavior.

Command
nice -n 10 yes > /dev/null &

nice starts a process with an adjusted scheduling priority. A higher nice value typically means lower CPU priority. This lets you run heavier workloads while reducing impact on interactive tasks.

[2] 1245

Reference

  • sleep 60 & : Runs a command in the background and returns to the prompt.
  • jobs : Lists jobs managed by the current shell session.
  • fg %<job> : Brings a job to the foreground (example: fg %1 ).
  • Ctrl+Z : Suspends the current foreground job (stops it without terminating).
  • bg %<job> : Resumes a stopped job in the background.
  • nice -n <value> <command> : Starts a command with adjusted scheduling priority (higher nice typically lowers priority).
  • yes > /dev/null : Generates continuous output redirected to null, commonly used as a simple CPU load test.