Schedule nightly restarts of the Automox agent on Linux endpoints for optimal performance
This Automox Worklet™ creates a cron job that automatically restarts the Automox agent service on Linux endpoints every night at 3:30 AM. The Worklet first checks whether the cron job already exists on the endpoint. If the job does not exist, the Worklet creates it.
The cron job includes a built-in safety check that prevents the restart if the agent is currently executing tasks. The job looks for execDir files in /var/lib/amagent/ and skips the restart if any are found. This maintains that the Worklet does not interrupt ongoing remediation or evaluation jobs.
Once installed, the cron job runs automatically without further intervention. You can manually modify the scheduled time in the cron configuration if needed, though you must remove the old entry before creating a new one.
The Automox agent is a long-running process that can accumulate memory usage, file handles, and connection pools over extended periods. Regular restarts clear these resources and help the agent maintain optimal performance. Periodic restarts also allow the agent to reload its configuration and pick up any updates from the Automox console.
Scheduling restarts during off-hours (like 3:30 AM) minimizes impact on your IT operations. The endpoint continues to report status to Automox after each restart, so you maintain visibility and can continue running other Worklets. Without regular restarts, long-running agents may eventually require manual intervention or cause endpoints to appear unresponsive.
This Worklet is particularly valuable for organizations managing thousands of Linux endpoints, where manual agent maintenance becomes impractical. Automating the restart process maintains consistency across your infrastructure and reduces the burden on your IT operations team.
Evaluation phase: The Worklet checks the existing crontab entries for an entry containing "service amagent restart". If the entry exists, the evaluation completes successfully and no remediation is needed. If no entry is found, the evaluation fails and triggers remediation.
Remediation phase: The Worklet creates a new cron job using the format "30 3 * * * /bin/bash -c 'ls /var/lib/amagent/execDir* &>/dev/null || service amagent restart'". This command runs at 3:30 AM every day, checks for running tasks, and restarts the service only if no tasks are executing.
Linux endpoints with the Automox agent installed
Root or sudo access to create and manage cron jobs
Bash shell available on the endpoint
Cron service enabled and running
No restrictions on modifying the user's crontab
After the Worklet runs successfully, the cron job will be installed and active on the endpoint. You can verify this by checking the crontab with the command "crontab -l" and confirming that the restart entry is present. The agent will continue normal operations immediately after the Worklet completes.
Each night at 3:30 AM, the cron job will check for active tasks and restart the agent if no tasks are running. You will not see any console notifications for the automatic restart, but the agent will reconnect to the Automox console shortly after. If you need to change the restart time, you must manually edit or remove the cron entry and run the Worklet again with your desired schedule.
Run this Worklet on a pilot Linux endpoint and review evaluation output for restart automox agent.
Confirm Automox activity logs show successful completion and exit code 0.
Verify endpoint state using checks aligned to evaluation script logic, such as exit, else.
Validate remediation effects from script operations such as exit, else, 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