Just wanted to see if any one had a good solution for scheduling a download time for the new Mac OS so it only uses my off peak hours. If this has already been discussed could some one point me in the right direction?
One of the most overlooked (and under used) apps. in OS X is Automator.
People don't use it because they find it intimidating however it is not that hard to use.
If you play with the app. you will quickly get a feel for it. It also allows you to "step" thru it to make sure you have it right.
I prefer manual updates and wait until there's a dot update for major OS releases. I have been burnt too many times on the "bleeding edge".
Since I don't allow automatic updates (but do allow automatically check for updates) I don't have a script that I can share with you.
You will want to check that an update is available and then run the /System/Library/CoreServices/Software Update.app. with time parameters you have scripted (based on your local time zone).
Hope this helps!
MarkJFine and I have been working on a plist to make off peak scheduling a reality for OS X users.
It's still under development and testing but you can follow along and contribute if you can. (see topic: Spot the rookie error)
Hopefully we'll have something to share soon.
The following guide is how I, after many years of searching and trying different methods, finally found a way to schedule macOS update downloads.
This guide tells one way to schedule the unattended download of a Macintosh OS update for a specific date and time of day. If your ISP (in my case Hughesnet) puts a cap on your monthly download data during part of the day but has a separate cap at night (in my case after 2AM) then this method will allow you to download the update without having to stay up half the night to do it. This worked for downloading the MacOS Big Sur 11.4 update to my iMac.
This method requires the use of the Terminal app found in the /Applications/Utilities folder and unix commands, in particular the cron scheduler and the softwareupdate command. I gather that “launchd” has superseded cron on the Mac but it still works for now. If the Terminal app and unix commands are new to you, I’ll explain as I go along.
First, backup your Mac in case anything goes wrong, not that it will.
We will be using commands visudo, crontab, and softwareupdate. You can read about these commands in a terminal session by typing “man command” without quotes, where “command” is the name of the command you want to know about, followed by the return key. This will display the manual “man” pages for the given command. Type the “space” key to see the next page of the manual or type “q” to quit the man page. We will also need to execute the softwareupdate command with root privileges. The command “sudo” in front of the command is used to gain superuser (root) privileges. However, the sudo command will usually ask for your user password before granting root privileges so we need to edit the sudoers file to not require the password, otherwise an unattended operation would not work. The sudoers file is edited with visudo. Needless to say, your user account has to be a member of the administrators group for sudo to work and to be able to download a system software update.
A note about vi (vim). The commands used to edit the configuration files we will be editing use the vi (vim) text editor. This in not your usual graphical user interface (gui) editor. It was designed for keyboard use before the advent of mice and graphical user interfaces. This editor is modal. We will be using the command mode and the insert mode. The editor opens in the command mode. Type “i” (without the quotes) to enter the “insert” mode. Use your cursor keys to move the insert cursor around the screen. You can enter or delete text at the cursor. You can also paste text at the cursor or select text with the mouse and copy it, but you can’t use the mouse to move the cursor. When you are finished editing, you press the “escape” key (esc) to enter the command mode, then “:wq” and “return key” to save your edits and exit the editor.
With these preliminaries out of the way let’s set up an automatic macOS update download for month mm, date dd, hour hh, an minute mi.
1. Open the Terminal app. This will open a terminal window with the unix shell prompt “%” in your user folder. You can type “ls -la” to see a list of all files and folders in your user folder. The file list command is “ls” and “-la” are command options that specify that a (l)ong list is to be returned with (a)ll files including hidden files. We will not be moving to a different folder. The terminal window opens rather small so you should make is bigger.
2. Enter a cron table entry to run the software update command and create a log of each attempted update. Type:
This opens the cron table editor. Type “i” to enter the insert mode then use your cursor keys to position the cursor. Edit the file to look like the following:
# min(0-59) hour(0-23) day(1-31) month(1-12) DayOfWeek(0-6)(0=Sunday) Command
mi hh dd mm * echo >>cronlog; date >> cronlog; sudo /usr/sbin/softwareupdate -d -r >> cronlog
Text following “#” is a comment showing the format of the cron table data. This simply says to execute a Command at the given time and date. An “*” in place of a number in one of these positions means “any”. Just substitute your desired time and date in place of mi, hh, dd, and mm. The Command being scheduled is actually three commands in sequence. The first command is “echo >>cronlog;”. This command creates a text file named “cronlog” in your user folder, if it doesn’t already exist, and appends a line feed character to it. You can name the file something else if you want to. The next command is “date >> cronlog;”. This appends the date and time the cron job is run to the cronlog file. The last command is “sudo /usr/sbin/softwareupdate -d -r >> cronlog”. This command invokes root privileges via “sudo” to run the software update command “/usr/sbin/softwareupdate -d -r”. The full file path to softwareupdate is given and the command options -d (download) and -r(recommended) are specified. Lastly the “>> cronlog” sends the output of softwareupdate to the cronlog file.
Note! The schedule and command must be in one line of text! This line of text wraps around in this guide because of its length, but it is only one line. You can add more lines to schedule other commands, but each schedule and command must be on a separate line. This is one reason to make the Terminal window wide enough to see the whole line of text.
When finished editing the crontab file, press the escape key to enter command mode, then enter “:wq” (without quotes) and return. This should (w)rite the edits to the crontab and (q)uit the editor. The unix shell prompt “%” should now be displayed.
You can issue command “crontab -l” to get a (l)isting of the cron table to check your work.
3. Give yourself root privileges to run “sudo /usr/sbin/softwareupdate -d -r” without having to type in a password. This is done by editing the sudoers file with editor visudo. Enter:
Since you are asking root privileges (via sudo) to edit the sudoers file, you will most likely be asked for your password. The system will then confirm that you are a member of the admin group and can then run visudo. If this is not the first time during this session you have run this command, the system will likely remember that your privileges have already been authenticated and not ask for your password.
After entering your password, the sudoers file should be displayed for editing. Using the cursor keys, scroll down to find the following text:
# root and users in group wheel can run anything on any machine as any user
root ALL = (ALL) ALL
%admin ALL = (ALL) ALL
Type “i” to enter insert mode then add the following below this text:
yourusername ALL = (ALL) NOPASSWD: /usr/sbin/softwareupdate -d -r
Substitute your user name for yourusername. The gives you permission to run command “softwareupdate -d -r” without typing in a password. You are finished editing this file so press escape to enter command mode then :wq to save your edits and quit the editor.
Your mac should now download the recommended system updates on your schedule. For the download to take place your mac must be on and prevented from sleeping in the Energy Saver System Preferences. I also found that you may need to boot your mac in safe mode (press shift key at boot) for the download to be completed.
After the scheduled download check your cronlog file to see how it went. If all went as planned, you can then open Software Update in System Preferences, and your update should be ready to be installed.