WEBTOOLIST.
STATIC WEB PLATFORM
NO ACCOUNTS / NOTHING TO INSTALL

$ webtoolist --script service-status-summary

Service Status Summary

Print active/inactive state for a list of systemd services.

category Linux Utilities shell Bash 4+ updated 2026-08-05
systemdservicesstatusutilities
Safety notes
  • Read-only: queries unit state only.
commands involved: ssh

Dependencies: systemctl

Usage

  • Edit the SERVICES list or set it in the environment.
  • Exit status is non-zero if any service is not active.

Script

#!/usr/bin/env bash
set -euo pipefail

read -r -a services <<< "${SERVICES:-ssh cron docker nginx}"
fail=0

for unit in "${services[@]}"; do
  state="$(systemctl is-active "$unit" 2>/dev/null || true)"
  enabled="$(systemctl is-enabled "$unit" 2>/dev/null || true)"
  printf '%-16s %-10s %s\n' "$unit" "${state:-unknown}" "${enabled:-unknown}"
  [[ "$state" == active ]] || fail=1
done

exit "$fail"

Example

./service-status-summary
SERVICES='ssh nginx postgresql' ./service-status-summary

Notes

  • is-active returns the state on stdout even for missing units; the script labels unknown explicitly.
  • Use systemctl list-units --type=service to discover the unit names on a new host.

Related scripts

Failed Service Report

List systemd units that are failed or restarting, with recent log lines.

System Administration

Service Health Check

Check systemd services and HTTP endpoints in one pass with a non-zero exit on failure.

Monitoring

PATH Audit

Check PATH for missing, duplicate, or world-writable directories.

Linux Utilities