Schedule Linux endpoint restarts after a configured number of uptime days
This Automox Worklet™ monitors endpoint uptime and automatically schedules a restart once a Linux endpoint exceeds a configurable number of days online. The Worklet calculates uptime in seconds from /proc/uptime and compares it against an administrator-defined threshold stored in the DayCounter variable.
The Worklet executes across Linux distributions including Ubuntu 20.04, RHEL 7, CentOS 7, AlmaLinux 9.1, and Fedora 36. When the endpoint's uptime in days meets or exceeds the configured threshold, the remediation phase schedules a reboot using the shutdown command with a one-minute delay to allow graceful service termination.
When the endpoint's uptime meets or exceeds the configured threshold, the remediation phase schedules a reboot with a one-minute delay to allow graceful service termination.
Periodic restarts are essential for maintaining system stability, applying kernel updates, and refreshing system memory. Long-running Linux endpoints can accumulate memory leaks, orphaned processes, and stale file handles that degrade performance over time.
Many security frameworks and compliance standards require regular endpoint reboots to clear temporary credentials, maintain critical patches activate, and reset system state. Automating restart scheduling maintains consistent policy enforcement across your infrastructure without requiring manual intervention or maintenance windows.
This Worklet saves IT operations teams time by eliminating manual uptime tracking and reducing the risk of forgotten endpoints running indefinitely without restarts.
Evaluation phase: The Worklet reads the current system uptime from /proc/uptime, extracts the uptime in seconds, converts it to days, and compares the result against the DayCounter variable. If uptime is less than the threshold, the evaluation exits successfully and no remediation is scheduled. If the threshold is met or exceeded, the evaluation exits with status 1 to trigger remediation.
Remediation phase: When triggered, the Worklet verifies the DayCounter variable is defined and then executes shutdown -r +1 to schedule a reboot one minute in the future. This delay allows running services and applications time to shut down gracefully.
Linux operating system: Ubuntu 20.04, RHEL 7, CentOS 7, AlmaLinux 9.1, Fedora 36, or equivalent distributions
DayCounter variable must be defined before Worklet execution. Set this to an integer representing the maximum uptime in days (for example, 30 for a 30-day restart cycle)
Standard system utilities available: grep, date, and shutdown commands
Root or administrative privileges to schedule system restarts
Access to /proc/uptime for reading system uptime information
After the Worklet runs, endpoints meeting the uptime threshold will have a scheduled restart queued for one minute in the future. Connected users will see a shutdown notification message informing them of the pending restart.
The endpoint will display the countdown time and reboot on schedule. Any unsaved work should be completed before the restart occurs. Once the restart completes, the uptime counter resets to zero, and the cycle begins anew. Endpoints with uptime below the configured threshold will show a status message indicating no restart is required, and the Worklet will not trigger remediation.
Run this Worklet on a pilot Linux endpoint and review evaluation output for restart after set days.
Confirm Automox activity logs show successful completion and exit code 0.
Verify endpoint state using checks aligned to evaluation script logic, such as function, exit, errMessage.
Validate remediation effects from script operations such as function, errMessage, exit, then rerun evaluation for compliance.


By submitting this form you agree to our Master Services Agreement and Privacy Policy.
Already have an account? Log in
Consider Worklets your easy button
A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

AUTOMOX + WORKLETS™
Uncover new possibilities with simple, powerful automation.
By submitting this form you agree to our Master Services Agreement and Privacy Policy