HxHippy

Service Monitor Script

Monitor services and auto-restart on failure.

Last updated: 2024-12-15

Service Monitor

#!/bin/bash
SERVICES=("nginx" "mysql" "redis")
while true; do
    for svc in "${SERVICES[@]}"; do
        systemctl is-active --quiet "$svc" || (echo "Restarting $svc"; systemctl restart "$svc")
    done
    sleep 60
done
intermediate Monitoring Updated 2024-12-15
  • service
  • monitor
  • systemd
  • restart
  • watchdog