I have a Mac running Sierra that runs without any user intervention to control hardware. Every night it is scheduled to reboot and it automatically logs in and opens our control software.

I need to ensure that it automatically installs security updates, but avoid having it automatically restart itself during the day. Is there any way to ensure that any automatically triggered restarts would only ever happen at night?

  • Use a configuration management system. May 26, 2017 at 15:47

3 Answers 3


I would suggest turning off automatic updates and scheduling a run of softwareupdate yourself. If you’re using shutdown to do the nightly reboot, you could turn that into:

softwareupdate --install --all; shutdown -r now

CNet has an introductory article on “How to apply OS X software updates from the command line”. Below, I’ve quoted sample output from a blog post (though an old one) where softwareupdate is used to install updates that require a restart. You might also be interested in an (old) hint on Mac OS X hints with a more complicated script that installs all available updates, reboots, and repeats the process until there are no more updates left.

iBook-G4:~ root# softwareupdate --install --all
Software Update Tool
Copyright 2002-2007 Apple

Downloading iLife Support       0..20..40..60..80..100
Verifying iLife Support
waiting iLife Support
waiting QuickTime
Downloading Mac OS X Update     0..20..40..60..80..100
Verifying Mac OS X Update
waiting Mac OS X Update
Installing iLife Support        0..20..40..60..80..100
Done iLife Support
Installing QuickTime    0..20..40..60..80..100
Done QuickTime
Installing Mac OS X Update      0..20..40..60..80..100
Done Mac OS X Update

You have installed one or more updates that requires that you restart your
computer.  Please restart immediately.

As mentioned above, a bash script would be the best way to accomplish this, when combined with a launch daemon to run it at a specific time. I would set updates to download but not install (except security updates which covers xprotect/gatekeeper), opting to do so via a script, which would contain something along the lines of

sudo softwareupdate -ir 
reboot now

All macOS updates which require reboot will start between 2am and 3am. This is currently not configurable. Updates which do not require an update will cause macOS to choose an appropriate time in the day.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .