Category filter
Script to Shutdown Mac
Users will typically select the Apple icon from the menu bar and select Shut Down to shut down a Mac. However, there are very few options available in the process, and device admins might want to execute such an operation remotely.
Hexnode already provides admins with the option to Power off devices from the console with a click, but with the below shell scripts, you can achieve even more granular control and automation over the shutdown power option on Mac.
Device admins can remotely run scripts on Macs managed with Hexnode using the Execute Custom Script action.
Scripting Language – Bash
File extension – .sh
Boot options on Mac
1 2 |
#!/bin/bash sudo shutdown -r now |
The shutdown
command closes down the system at a given time. Some of the options supported with the command are –
-r
– The system is rebooted at the given time.-h
– The system is halted at the given time.-s
– The system is put to sleep at the given time.- time – The time at which the system will execute the shutdown command. now indicates immediately. To schedule the action, use the format +number (in minutes) or yymmddhhmm. Example –
shutdown –r +60
(wait for an hour before shutdown)shutdown –r 2109142134
(schedule shutdown on September 14, 21:34:00 2021) - warning message – Any other arguments not having a function is passed as the warning message. Example –
sudo shutdown –r +5 “The system will restart in 5 mins”