Services and processes
Diagnose a failed unit
Read systemd result, exit status, effective configuration, and journal before repeatedly restarting a service.
8 minute lesson
systemctl status gives a useful summary, but the full explanation usually needs more evidence.
Inspect Result, ExecMainStatus, the unit journal, and systemctl cat. Check referenced users, paths, files, and ports. Validate application configuration with its own check command.
Break a disposable service through one invalid path. Capture the manager result and journal, repair it, and prove the service stays healthy after restart.
Capture state before restarting the service:
systemctl --failed
systemctl status app.service --no-pager
journalctl -u app.service -b -n 100 --no-pager
Find when the failure began and what changed just before it. Check the process exit status, user, paths, ports, and dependencies. Restart only after you have enough evidence to test one explanation, then verify the user-facing endpoint.
Lesson completed