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
- SSH into the Jumpbox and create
~/m2-assignment2; keep your notes filereport.mdthere. - List running processes with
ps auxand again withtop(quittopwithq). In your report, name the process with PID 1 and explain what it is. - Pick the
cronservice (the scheduler, always present on Ubuntu) as your subject. Check its state withsystemctl status cron. Record whether it isactiveand whether it isenabled, and explain the difference between those two words in your own words. - Confirm boot behavior explicitly with
systemctl is-enabled cron. - Read the service's logs:
journalctl -u cron -n 30. Paste the last few lines into your report. - Practise the control verbs (these are safe on
cron):sudo systemctl restart cron, then immediately re-checksystemctl status cronand confirm the "Active: active (running) since ..." timestamp updated to just now. - Watch logs live: run
journalctl -u cron -fin your terminal, note that it follows, then stop it withCtrl-C. Record what-fdoes. - Find logs on disk too: list
/var/log, then usetail -n 20 /var/log/syslog(withsudoif needed). In your report, name the two places service logs live on this host and state where they are also centrally shipped. - Signals: start a harmless background sleep with
sleep 600 &, note its PID (echo $!orps aux | grep sleep), stop it withkill <PID>(SIGTERM), and confirm withpsthat 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.mdexists 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
activeandenabledstatus and correctly explains active vs enabled. - The report includes a
journalctl -u cronlog snippet. - The report shows evidence (the updated "Active ... since" timestamp) that
systemctl restart cronworked. - The report explains what
journalctl -u cron -fdoes. - The report names both log locations (the systemd journal and
/var/log/...) and states logs also ship to the central Loki server at10.100.100.5. - The report records a
sleepPID that you killed and identifies SIGTERM as signal 15.
Hints
- The troubleshooting loop is always:
systemctl status <svc>to see that something happened, thenjournalctl -u <svc> -n 50to see why. - A service can be
activebutdisabled(running now, won't survive reboot) orenabledbutinactive(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
cronis your subject for restart practice — don't restartsshwhile 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.
No comments to display
No comments to display