Skip to main content

Assignment 2: Manage a service and read its logs

Goal: Prove you can inspect, control, and troubleshoot a systemd service and read its logs — the core operations loop from Chapter 5.

Where: The Jumpbox (10.100.100.254, user ubuntu, passwordless sudo). Work in a new directory ~/m2-assignment2.

Tasks

  1. SSH into the Jumpbox and create ~/m2-assignment2; keep your notes file report.md there.
  2. List running processes with ps aux and again with top (quit top with q). In your report, name the process with PID 1 and explain what it is.
  3. Pick the cron service (the scheduler, always present on Ubuntu) as your subject. Check its state with systemctl status cron. Record whether it is active and whether it is enabled, and explain the difference between those two words in your own words.
  4. Confirm boot behavior explicitly with systemctl is-enabled cron.
  5. Read the service's logs: journalctl -u cron -n 30. Paste the last few lines into your report.
  6. Practise the control verbs (these are safe on cron): sudo systemctl restart cron, then immediately re-check systemctl status cron and confirm the "Active: active (running) since ..." timestamp updated to just now.
  7. Watch logs live: run journalctl -u cron -f in your terminal, note that it follows, then stop it with Ctrl-C. Record what -f does.
  8. Find logs on disk too: list /var/log, then use tail -n 20 /var/log/syslog (with sudo if needed). In your report, name the two places service logs live on this host and state where they are also centrally shipped.
  9. Signals: start a harmless background sleep with sleep 600 &, note its PID (echo $! or ps aux | grep sleep), stop it with kill <PID> (SIGTERM), and confirm with ps that it's gone. Record the PID and the signal name SIGTERM corresponds to.

Deliverable

A file /home/ubuntu/m2-assignment2/report.md documenting tasks 2–9: the PID 1 process, cron's active/enabled state with the difference explained, its is-enabled result, a snippet of its journal, evidence the restart updated the start time, what journalctl -f does, the two log locations plus the central Loki destination, and the sleep-process PID you killed with the signal name.

Acceptance criteria — you're done when:

  • report.md exists at /home/ubuntu/m2-assignment2/report.md.
  • The report identifies PID 1 as systemd (/sbin/init) and explains what it is.
  • The report states cron's active and enabled status and correctly explains active vs enabled.
  • The report includes a journalctl -u cron log snippet.
  • The report shows evidence (the updated "Active ... since" timestamp) that systemctl restart cron worked.
  • The report explains what journalctl -u cron -f does.
  • The report names both log locations (the systemd journal and /var/log/...) and states logs also ship to the central Loki server at 10.100.100.5.
  • The report records a sleep PID that you killed and identifies SIGTERM as signal 15.

Hints

  • The troubleshooting loop is always: systemctl status <svc> to see that something happened, then journalctl -u <svc> -n 50 to see why.
  • A service can be active but disabled (running now, won't survive reboot) or enabled but inactive (will start at boot, not running now) — they're independent.
  • & puts a command in the background; echo $! prints the PID of the last backgrounded job.
  • Only cron is your subject for restart practice — don't restart ssh while you're connected through it, or you may interrupt your own session.
  • Blocked for >~30 min after re-reading the lessons? Bring what you've tried to your mentor.