Sunday, May 9, 2021

#1 2008-09-02 10:53:03 am

micahboswell
Member
Registered: 2008-09-02
Posts: 2

Software Update: Looking for a Script to Control

The Mac OS X Software Update does not allow for control beyond Weekly/Daily/Monthly setting.

Is there a way I can set it to run at a specific hour via a script?

Last edited by micahboswell (2008-09-02 10:57:28 am)

Offline

 

#2 2008-09-02 11:06:06 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11746
Website

Re: Software Update: Looking for a Script to Control

Hi,

install a launchd agent, which runs /usr/sbin/softwareupdate at a specific time
You can install the updates automatically, or if you want to see the GUI window before installing, list the updates.
If the list is not empty, launch the Software Update PrefPane with GUI scripting.

PS: Personally I don't understand, why the daily option isn't sufficient


regards

Stefan

Offline

 

#3 2008-09-02 11:13:17 am

micahboswell
Member
Registered: 2008-09-02
Posts: 2

Re: Software Update: Looking for a Script to Control

Thanks for the info!

So, here's the deal.  A buddy of mine uses a limited bandwith/download system via satellite.  But he gets unlimited bandwidth from 2 to 5 am.  So, he's trying to find a way to set Apple's 'Software Update' to 2 am.

Thanks again!

As well, might you point me in a direction where I could get a tutorial as to how to write the Launchd agent?  I'm a noob.

Offline

 

#4 2008-09-02 12:32:55 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11746
Website

Re: Software Update: Looking for a Script to Control

As Software Update must be run as root, the launchd agent must be placed in the main library.
The agent opens the application Software Update directly, the appearance is the same as calling it from the PrefPane

1) Create a plain text file, with the contents below, and save it on your desktop as software.update.plist with UTF-8 text encoding.
The time is set to 16:00 (4 pm), change the numbers of the Hour / Minute keys to the value you want (24 hr mode!)

[code]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>software.update</string>
    <key>LowPriorityIO</key>
    <true/>
    <key>Program</key>
    <string>/System/Library/CoreServices/Software Update.app/Contents/MacOS/Software Update</string>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>16</integer>
        <key>Minute</key>
        <integer>0</integer>
    </dict>
</dict>
</plist>[/code]
2) Check if the folder /Library/LaunchAgents exists (important: the library on the root level of the startup volume)
If the folder exists, drag the file software.update.plist into /Library/LaunchAgents. You will be prompted to authenticate.
Copy the following line in a terminal window, press return and type in your admin password (there is no echo!)
[code]sudo chown root:wheel /Library/LaunchAgents/software.update.plist[/code]
if the folder doesn't exist, create a folder LaunchAgents on your desktop, put the file into it and drag the folder into /Library. You will be prompted to authenticate.
Copy the following line in a terminal window, press return and type in your admin password (there is no echo!)
[code]sudo chown -R root:wheel /Library/LaunchAgents[/code]
3) Activate the agent with
[code]sudo launchctl load -w /Library/LaunchAgents/software.update.plist[/code]

Last edited by StefanK (2008-09-02 12:39:25 pm)


regards

Stefan

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)