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; doneIn 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
journalctl Command Reference: Flags, Usage & CI ExamplesReference for journalctl: -u, -f, --since, -n, -p, -b, and a CI example that dumps a failing service unit log…
service Command Reference: Usage & CI ExamplesReference for the service command: start, stop, status, --status-all, the SysV/init wrapper role, and a CI ex…
ps Command Reference: Flags, Usage & CI ExamplesReference for ps: aux, -ef, -o custom columns, --sort, and a CI example that lists running processes to debug…