πŸ”„ Safe Service Restart

Restart services with pre-checks and rollback guidance

Restart a systemd service safely. Records state before restart, runs your custom health check before and after, waits for the service to come back up, and prints recent logs if something fails.

Features

  • βœ… Pre-check and post-check with custom commands
  • βœ… Configurable wait time for service to become active
  • βœ… Auto-shows journalctl logs if restart fails
  • βœ… Records PID + uptime before restart for audit trail
  • βœ… Color-coded step-by-step output

Usage

./service-restart-tamer.sh nginx
./service-restart-tamer.sh postgresql --wait 30
./service-restart-tamer.sh my-app --pre-check "curl -s http://localhost:8080/health" --post-check "curl -f http://localhost:8080/health"

Download

Get the script from the Free Tools Pack, or grab it directly:

# Clone from the repo (scripts are in /products/free/)
curl -O https://pragmaticsysadmin.help/downloads/service-restart-tamer.sh
chmod +x service-restart-tamer.sh
./service-restart-tamer.sh --help

License

MIT β€” use, modify, redistribute.

Support

Bugs or questions: pragmatic@pragmaticsysadmin.help

More tools

See /shop/ for the full catalog, including paid toolkits:


Made with care by Pragmatic Sysadmin.