brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: systemctl --failed lists every service that did not start

Linux
~/tips/tip-systemctl-failed

systemctl --failed

Lists every service that failed to start, so you know after a reboot if everything came back.

After a reboot or an update I want one answer: did everything come back? On a systemd Linux box such as Ubuntu or Debian there is a single command that answers it, plus a short routine for when it does not.

systemctl --failed

It prints only units that are in a failed state. The best output is 0 loaded units listed. Anything else is a service that tried to start and gave up, a timer job that errored, or a mount that did not come up. Add --type=service to hide sockets and mounts when you only care about daemons.

Take the name from the first column and ask for details:

systemctl status nginx.service
journalctl -u nginx.service -b --no-pager | tail -50

status shows the exit code and the last few log lines. journalctl -u shows the full log of that unit, and -b limits it to the current boot so older noise is gone. The error message in there is almost always the answer: a port already in use, a missing file, a typo in a config.

Restart the service and check it:

sudo systemctl restart nginx.service
systemctl is-active nginx.service

A unit stays in the failed list until it is cleaned up, even if it works again. sudo systemctl reset-failed clears the list (or give it one unit name), so next time --failed only shows new problems.

  • systemctl list-timers shows scheduled jobs and when they last ran.
  • systemd-analyze blame lists what slowed the boot down.
  • systemctl --user --failed does the same for your own user services.

Not every system uses systemd. Unraid, for instance, does not, so this tip is for Ubuntu, Debian, Fedora and similar distributions. On a Raspberry Pi running Raspberry Pi OS it works as written.

Further reading: systemctl manual (freedesktop.org)

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link