Scheduling OSX system updates
February 3, 2009 12:11 AM   Subscribe

How do I specify the time of day of OSX system update downloads?

I would like to schedule OSX 10.5 system updates to download all updates at 5am each day (ideally without installing them, but I can probably live with them being installed). The system preference pane allows me to specify daily or weekly, but not to specify what time to perform the download. Can this be done?
posted by pompomtom to Computers & Internet (4 answers total) 2 users marked this as a favorite
Actually, this suggests that I set the time period, and then do a manual check at 5am... I'm sort of hoping there's a plist file hidden somewhere that I could edit, rather than getting up at 5 one morning to do it.
posted by pompomtom at 12:19 AM on February 3, 2009

Personally I would turn off automatic updates in Software Update, then just use Automator to write a little script that has whatever time you want specified.
posted by fearnothing at 1:33 AM on February 3, 2009

looks like the setting is per-user, and stored in ~/Library/Preferences/

"defaults read" will show the relevant entry (and perhaps others besides SoftwareUpdate).

Rather than figuring out how to use the defaults command to modify this, or installing Xcode to get the property list editor, you might find it easier to set your system clock to 5am, check for updates, and then correct your system clock.

I hate tweaking with the system clock, so here's another idea:

using "softwareupdate --schedule on" will "touch" the scheduled update time. Use the GUI to change your monthly/weekly/daily setting, then use "softwareupdate --schedule on" to cause the time in to be updated.

You can use "at" to run this once, at the right time.

Of course, "at" is disabled by default... and I wasn't able to get it to run softwareupdate when I *did* enable it, so...

At least that's something to go on.

FWIW, I tried:

Enable "at" for now with:
launchctl load -F /System/Library/LaunchDaemons/

Then schedule a one-off run of softwareupdate:
echo "softwareupdate --schedule on" | at 5:00am

crond runs atrun every 10 minutes by default, so it won't run exactly at 5:00 AM...

But when the job executed, I got:
atrun[2190]: cannot regain privs: Operation not permitted

So, edit the plist file, or mess with the system clock, or fix my atrun problem, or find another way to schedule a call to softwareupdate --schedule on

There's probably another, easier way. :-)
posted by ffej at 1:50 AM on February 3, 2009

the atrun manpage is outdated. cron no longer calls atrun every 10 minutes, launchd runs it every 5 minutes... but it's disabled by default.

my earlier attempt to start atrun with launchd failed, because i didn't use sudo.

#stop atrun if you tried to start it earlier like I did:
launchctl unload /System/Library/LaunchDaemons/
#use GUI to set scheduled updates on, and pick daily/weekly/monthly
sudo launchctl load -F /System/Library/LaunchDaemons/
# if you already scheduled an at job, it should be visible with "atq"
# like this: 1 Tue Feb 3 04:32:00 2009
# and you can remove it with "atrm " (in this case "atrm 1")
# schedule a job to "touch" the scheduler timestamp
echo "softwareupdate --schedule on" | at 5:00am
#wait until after 5:05am, and verify:
defaults read

Using load -F forces the disabled atrun to load, but does not change its disabled configuration. you can stop it later with "sudo launchctl unload /System/Library/LaunchDaemons/" or you can just reboot. It's supposedly disabled due to power management concerns.

Your user will probably need to be logged in for this to work. I don't know if you can run scheduled updates when there isn't a user logged in, and i don't know what happens if you're not logged in when the scheduled time comes. It might run when you log in, and possibly reset your "5:00 AM" setting as well.

Apple probably doesn't care much about making this easier to do. Currently, it's somewhat of a self-randomizing thing, which is good for server load.

If it's just the downloads you care about scheduling, you might want to call softwareupdate with the proper arguments on a scheduled basis, and disable the schedule options in the Software Update GUI.

This is all tested on OS X 10.4.11. Earlier/later versions may differ.

posted by ffej at 2:28 AM on February 3, 2009

« Older What's that quote about wage inequity?   |   "It was a quarter past two when Moses parted the... Newer »
This thread is closed to new comments.