Skip to content
Latchkey

systemctl Command Reference: Flags, Usage & CI Examples

systemctl controls and inspects systemd services and units.

systemctl starts, stops, enables, and queries systemd units. On self-hosted runners and VMs it manages background services; the key CI caveat is that most containers do not run systemd.

Common flags and usage

  • start / stop / restart <unit>: control a service
  • status <unit>: show state and recent log lines
  • is-active <unit>: print active/inactive (scriptable)
  • enable --now <unit>: enable at boot and start now
  • list-units --failed: show units that failed
  • daemon-reload: reload unit files after editing them

Example

shell
sudo systemctl start postgresql
until systemctl is-active --quiet postgresql; do sleep 1; done

In CI

On a self-hosted runner, gate on systemctl is-active --quiet so a job waits for a service before using it. Inside most Docker containers there is no PID 1 systemd, so systemctl fails with "System has not been booted with systemd" -- use the service binary or the service command instead.

Key takeaways

  • systemctl manages systemd units on VMs and self-hosted runners.
  • is-active --quiet is the scriptable readiness check.
  • Most containers lack systemd, so systemctl will not work there.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →