-
Notifications
You must be signed in to change notification settings - Fork 6
reboot_on_uptime_macos.sh
Corey Watson edited this page Dec 1, 2025
·
1 revision
Automatically reboots a macOS or Linux system if the uptime exceeds a specified threshold.
This script monitors system uptime and triggers an automatic reboot when the system has been running longer than a configured threshold (default: 14 days). It works on both macOS and Linux systems.
Automatically reboots a macOS or Linux system if the uptime exceeds a specified threshold (default: 14 days).
- macOS or Linux with /proc/uptime (Linux) or uptime command (macOS)
- Root/sudo privileges
-
max_uptime_days: Days of uptime before triggering reboot (default: 14)
- Detects the operating system (macOS or Linux)
- Retrieves current system uptime in days
- Compares uptime against configured threshold
- If uptime exceeds threshold, triggers immediate reboot
- If within acceptable range, exits without action
- Requires root/sudo privileges to execute reboot command
- No sensitive information logged
- 0 = Success (reboot triggered or not needed)
- 1 = Failure
[ UPTIME CHECK ]
--------------------------------------------------------------
Current Uptime : 16 days
Threshold : 14 days
[ FINAL STATUS ]
--------------------------------------------------------------
Uptime exceeds threshold. Rebooting now...
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
- v1.0.0 - Initial release
- View Script Source
- Scripts - Back to script index