π 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:
- The 5-Minute Server Health Check Toolkit ($9) β the “do everything” Monday morning ritual
Made with care by Pragmatic Sysadmin.