If a person is logged in, subject the Open Scripting Structure (OSA) command from throughout the person session:
osascript -e 'inform software "System Occasions" to restart'
This may also be referred to as from an AppleScript or Automator workflow.
If no-one is logged in, use the shutdown command line device:
shutdown -r now
Variations in Strategy
Apple’s softest method to shutting down is through the Finder > Apple > Shut Down menu merchandise. This method sends graphical purposes a request to give up through an AppleEvent; at this stage purposes can block the shut down if knowledge is in danger.
Non-graphical purposes, these that don’t perceive AppleEvents, are despatched a terminate sign.
Restarting is 2 step: a shut down, adopted by instantly powering again on.
See Shutting Down Your Mac Safely that talks concerning the completely different phases of shutting down.
shutdown -h now is essentially the most forceful method and will prevented when a person is logged in. It’s because purposes will probably be give up with much less alternative to avoid wasting unsaved work.
A restart with the shutdown device is initiated with:
shutdown -r now
Scripting Restart and Shut Down
In case you are scripting a restart or shut down, check out Scheduling a Shut Down on macOS, which walks by means of varied approaches:
- built-in through Power Saver
- third occasion instruments like Energy Supervisor
- AppleScript with
inform software "System Occasions" to restart shutdown -r now
