Set night time updates on Mac OS
These instructions are useful to set your Mac OS to check for updates during night-time hours or during off peek internet usage.
We need to create a plist and then schedule it to run. To start.
Create the Plist file:
This is the LaunchDaemon plist file; just save it as myfile.plist in /Library/LaunchDaemons.
You can, of course, adjust the schedule according to your own wishes.
Set Permissions on Plist:
Ensure you set root permissions on the Plist so it can run.
Create the Script:
Here is the "softwareupdate" script that does the dirty work. Put it in /usr/local/sbin, or somewhere else on your path. If you store it elsewhere or change the script name, change the path in the above plist file to point to the new location.
This script does two things, it creates a system notification that an update check is about to happen. Then is checks for all mandatory and optional updates. You can change the notifications sgrings to your liking. Check out the documentation on Mac OS's softwareupadte utility to learnmore about the shown arguments and other arguments or options that may apply to your unique needs.
Set Execute on the Script:
Remember to chmod +x
the script file, so it can run. Note that this script is using Zsh not Bash. Zsh is now the preferred default shell on Mac OS. To ensure the script is set to as executable run:
Chmod +x %path to your script%
You can check that your service is available by running:
sudo launchctl list
Scroll thru the list of services and look for "info…".
Wrapping up
At this point you need to make sure the Mac is awake at the scheduled time and it will automatically check for updates, download and install. It will restart as necessary.