How do I check whether a Linux service is running, failed or missing?
systemctl reports the state of services managed by systemd. Active means the unit is in an active state according to its configuration; it does not prove that a website, database or queue is responding correctly. Check the exact installed unit name and then use the application’s own health test.
Before you start
- An authorised SSH session on the Linux server.
Instructions
1. Inspect the named service
Replace example.service with the unit documented for your installed application. Names differ between distributions, such as ssh.service and sshd.service.
systemctl status example.service --no-pager
systemctl is-active example.servicestatus includes recent context; is-active gives a compact state and an exit status useful in scripts. A nonzero status requires interpretation.
2. Check failed or installed units
If the name is uncertain, inspect the service inventory rather than guessing a restart command.
systemctl --failed --type=service --no-pager
systemctl list-unit-files --type=service --no-pagerThe first command finds failed loaded services. The second lists installed unit files, including units that are not currently running.
Check the result
- The expected unit is present, its state is understood, and the application’s user-facing or local health check succeeds.
Troubleshooting
- Unit not found is returned
- Verify the package, unit name and deployment method; the application may run in a container or another supervisor.
- The state is active (exited)
- A oneshot service may have finished successfully. Read its unit type and expected behaviour before treating it as a daemon.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
