Category filter
Script to schedule restart on Mac
Periodic rebooting of Mac is a good practice to ensure the devices work in top conditions. It regularly clears apps’ memory, fixes peripheral and hardware issues, improves device performance, and much more. However, administrators cannot completely rely on the end-users to perform the restart action occasionally. Most users prefer to keep their devices running all the time, making them ready for action whenever they need to. In such circumstances, IT can take advantage of the custom scripts in Hexnode to schedule the periodic restart of their Macs remotely.
Scripting language – Bash
File extension – .sh
Schedule restart on macOS devices
1 2 3 |
#!/bin/bash sudo shutdown -r hhmm |
The
command is used to shut down the system. The option shutdown
is used to specify that the system should reboot after the shutdown process is initiated.Replace -r
hhmm
with the hour and minute (in 24-hour notation) at which you need to schedule the restart of your managed devices. Once the script is executed, the devices will be rebooted at the specified time.
What happens at the device end?
Case 1: If the Terminal app is open at the device end
On executing the script, a badge notification appears on the Terminal app. On opening it, a message saying that the system is going down in ‘x’ minutes is displayed for each passing minute and finally show ‘System going down in 30 seconds’.Then the device will proceed to restart.
Case 2: If the Terminal app is closed at the device end
On opening the Terminal app, ‘System going down at hh:mm’ is displayed.