Systems study
Offline — showing the cached copy.
Home / Linux / 4. systemd: services, timers, journal

4. systemd: services, timers, journal

One-liner. Units describe what to run; systemd decides when, how often, and what to do on failure.

Memorize

  • Unit types: .service, .timer, .socket, .target, .mount, .path.
  • Dependencies: Requires= (hard), Wants= (soft), After=/Before= (ordering only — ordering is not dependency).
  • Restart=on-failure, RestartSec=, StartLimitBurst= guard crash loops.
  • Socket activation: systemd owns the socket and starts the service on first connection.
  • systemctl daemon-reload after editing units; enable --now for boot + start.
  • journald: journalctl -u name -f, -b, -p err, --since, -o json.
  • Hardening knobs: NoNewPrivileges, ProtectSystem=strict, PrivateTmp, ProtectHome, DynamicUser.
SERVICE LIFECYCLE Boot target unit start ExecStart running exit ok: stop exit fail:Restart journal
Service lifecycle

Trap. Writing After=network.target and assuming networking works — the network may be up without DNS or routes. Do this. Depend on what you actually need (network-online.target, a health check, or retry in the app).

Check

What is the difference between Requires= and After= in a systemd unit?