Signal9Signal9 — home
online
back to labs

Run a Job in the Background — and Keep It Running

MediumCommand Line Essentials10-15 min
The brief

A monitor needs to run in the background and survive your shell closing. The program /usr/local/bin/sysmon.sh runs forever, printing a status line every few seconds. Right now it isn't running.

Start it so that (1) it runs in the background — your prompt returns immediately and it keeps going — and (2) everything it prints ends up in /root/sysmon.log. Grading reads the running process and the log, not your keystrokes, so any spelling that gets both right will pass.

Three ideas have to come together: putting a job in the background, sending its output — and its errors — to a file instead of your screen, and keeping the process alive once the shell that started it is gone. That last one is the part people miss: a backgrounded job is still the shell's child, and an exiting shell hangs its children up.

Check your work with jobs, pgrep -f sysmon.sh, and tail /root/sysmon.log.

What you'll do
  • Start /usr/local/bin/sysmon.sh so it keeps running in the background
  • Capture everything it prints — stdout and stderr — in /root/sysmon.log
  • Make sure it survives the shell that launched it

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.