Pcornel
Linux · systemd & Services

Service Dependencies

Cheat sheet · https://pcornel.dk/topic.php?topic=2721

Back to the Topic

Answer

Service dependencies tell systemd what must also start (Wants=, Requires=) and in which order (After=, Before=). They are separate: Requires= without After= starts both at the same time.

Remember

Use After=network-online.target plus Wants=network-online.target for services that need a configured network. Use RequiresMountsFor=<path> for data on a mount. Prefer Wants= over Requires= unless the service truly cannot run without the other.

First checks

  • systemd-analyze critical-chain <unit> — what the unit waited for
  • systemctl status <unit> — state, main PID, recent log lines
  • systemctl list-units --failed — failed units
  • journalctl -u <unit> -b — the unit's log since boot
  • systemctl cat <unit> — unit file plus drop-ins
  • systemd-analyze verify <unit> — unit file errors

Verify in this order

unit requested → Wants/Requires add other units → After/Before order them → units start in order

Where it usually breaks

First mismatch in persistent unit/config/generator → dependency/order graph → systemd state → process/cgroup → socket/resource dependency → journal → consumer check; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2721

Confirmation

Confirm action

Continue?