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
sudo shutdown -r hhmm
command is used to shut down the system. The option
is used to specify that the system should reboot after the shutdown process is initiated.Replace
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.