How do I schedule a graceful Linux server reboot and cancel it if necessary?
A reboot interrupts every workload on that server, not just the component being maintained. Confirm the maintenance window, application shutdown behaviour and out-of-band recovery access first. Use a graceful operating-system reboot so services can stop in their documented order; a provider power reset is a different action.
Before you start
- An authorised SSH session on the Linux server.
Instructions
1. Check current work and readiness
Inspect logged-in users and failed services before maintenance. Coordinate application drains, clustered roles and scheduled jobs through their established procedures.
who
systemctl --failed --no-pagerThis is a baseline, not proof that all background work has finished. Confirm the affected applications separately.
2. Schedule the approved reboot
On a systemd-based server, the example schedules a reboot in ten minutes and broadcasts a maintenance message to logged-in terminals.
sudo shutdown -r +10 "Approved server maintenance"This is a real disruptive action when executed. Keep console access available and do not schedule it without a confirmed maintenance window.
3. Cancel only if the plan changes
Before the shutdown begins, cancel the pending operation if maintenance has been withdrawn.
sudo shutdown -cCancellation is an alternative action, not a step to run after every scheduled reboot.
Check the result
- After the reboot, SSH reconnects to the expected host, uptime reflects the restart and critical applications pass their own health checks.
Troubleshooting
- SSH does not return
- Use the authorised provider console to distinguish boot, network and SSH-service failures; avoid repeated forced resets.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
