Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automatic Updates via Terminal

Hello,


Just wondering if anyone out there has any experience customising App Store automatic updates via Terminal.


I do know that using the following command (softwareupdate --schedule off), will completely disable automatic updates. What I'm trying to do however, is use Terminal to customise automatic updates even further.


What I'd like to have done is this:


- Enable Automatically check for updates

-> Enable Install system data files and security updates


User uploaded file


Does anyone know of a terminal command to configure automatic updates as show above? I could simply do this through the GUI but I'd rather send out the terminal command to our Mac users remotely.


Cheers!

Posted on Nov 20, 2014 5:51 PM

Reply
Question marked as Best reply

Posted on Jan 31, 2015 6:25 PM

In Terminal…


osascript -e "tell application \"System Preferences\" to quit"
sudo softwareupdate --schedule off
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool YES
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool YES

The reason for quitting System Preferences & setting software update to off is because of how 10.10 caches the defaults system.

See the note inside the description in the manual…

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/defaults.1.html

For anyone messing with actual plist files see this tip or learn to live with failure…

http://www.cnet.com/how-to/how-to-manually-edit-defaults-plist-files-in-maverick s/


Basically don't mess with running apps & expect defaults write to work all the time, they may decide to flush their caches (I expect someone here can explain this in a more accurate way, or point to good docs - please step in).

System Preferences or softwareupdated can overwrite your 'defaults writes', so the simplest way to make any changes is to ensure they cannot step on your toes.


Does this help ACCCEM?

14 replies
Question marked as Best reply

Jan 31, 2015 6:25 PM in response to ACCCEM

In Terminal…


osascript -e "tell application \"System Preferences\" to quit"
sudo softwareupdate --schedule off
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool YES
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool YES

The reason for quitting System Preferences & setting software update to off is because of how 10.10 caches the defaults system.

See the note inside the description in the manual…

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/defaults.1.html

For anyone messing with actual plist files see this tip or learn to live with failure…

http://www.cnet.com/how-to/how-to-manually-edit-defaults-plist-files-in-maverick s/


Basically don't mess with running apps & expect defaults write to work all the time, they may decide to flush their caches (I expect someone here can explain this in a more accurate way, or point to good docs - please step in).

System Preferences or softwareupdated can overwrite your 'defaults writes', so the simplest way to make any changes is to ensure they cannot step on your toes.


Does this help ACCCEM?

Dec 23, 2014 10:26 AM in response to Linc Davis

Thanks Linc,


That enables/disables the "Automatically check for updates" (think we can also use softwareupdate --schedule on)

but i can't find anything to disable/enable "Install system data files and security updates"


When ticking it on/off it makes no changes to /Library/Preferences/com.apple.SoftwareUpdate.plist so i'm wondering where it changes ?


ACCCEM, did you have any success with this ?


Thanks, Andy

Dec 23, 2014 2:07 PM in response to iampob

Hi iampob,


I had some success but it was through trial and error. I couldn't ever get a consistent result. I tried reasoning that whatever configuration was set in the App Store preferences, those changes would be subsequently written to the com.apple.SoftwareUpdate.plist file.


After getting the App Store preferences set, I decided to take a peek into the plist file and noticed that some of the settings were configured while others simply were not present. In either case, here's what I did with moderate success (please note that I'm using a piece of software called "Packages" that builds distribution files):


1. Configure the App Store preferences as needed

2. Create a shell script with the following command:


sudo cp -av /tmp/"com.apple.SoftwareUpdate.plist" /Library/Preferences


(please note that the /tmp directory as seen above is one that I created in the "Packages" application)


3. Create my distribution file with all necessary files

4. Deploy .mpkg file that's created




Alternately, you could simply copy the com.apple.SoftwareUpdate.plist file from /LibraryPreferences from the source computer (after configuration) and paste it on your target machine in the same location.


This may/may not help you. I'm in the dark with it still.

Jan 31, 2015 1:12 PM in response to ACCCEM

I have just written an Applescript that will do just what you are asking. I have posted it here for you. It still needs some work, as in it could be shortened a bit plus some of the code could be technically better but it works.

I had a problem whereby OS X Yosemite would not check for updates on t's own. it would only do so if I did it manually. I tried everything I could think of so finally wrote a script to do so which I then add to a calendar reminder so that on that day/time the script will run triggering the checks. The script get's the settings from the ones you set in app store settings(screen shot above)

hope it helps


-- Apple script to check for Updates in OS X Yosemite.

-- For some reason OS X Yosemite does not do this for all people

-- Copyright Dawson 2015 all rights and copy rights will be retained by me at all times

-- though the user is entitled to make any edits as required


-- tell finder to read the file com.apple.SoftwareUpdate.plist and copy it to a variable.

-- Then take each variable of the file that is used to store choices the user makes as

-- to checking, downloading and installing of updates and copy them to other variables.

-- Then if each of the variables are TRUE get softwareupdate to perfrom that action


tell application "Finder"

set myfile to "/Library/preferences/com.apple.SoftwareUpdate.plist"

set sourcepath to POSIX path of myfile

do shell script "cp -r " & sourcepath's quoted form & " ~/Desktop/"

do shell script "plutil -convert xml1 /Users/touchdown/Desktop/com.apple.SoftwareUpdate.plist"

set myfile to "~/Desktop/com.apple.SoftwareUpdate.plist"

set thetext to (readmyfile)


tell application "System Events"

tell property list filemyfile

tell contents

set automaticcheckenabledcopy to value of property list item "AutomaticCheckEnabled"

if automaticcheckenabledcopy = true then do shell script "softwareupdate -l"

set automaticdownloadcopy to value of property list item "AutomaticDownload"

if automaticdownloadcopy = true then do shell script "softwareupdate -d"

set configdatainstallcopy to value of property list item "ConfigDataInstall"

if configdatainstallcopy = true then do shell script "softwareupdate -i --install -a"

set criticalupdateinstallcopy to value of property list item "CriticalUpdateInstall"

if criticalupdateinstallcopy = true then do shell script "softwareupdate -i --install -r"

end tell

end tell

end tell

do shell script "rm –Rf ~/Desktop/com.apple.SoftwareUpdate.plist"


end tell

Jan 31, 2015 6:47 PM in response to Drew Reece

Here are the other keys cover the checkboxes in the 'System Preferences > App Store Preferences', except I can't get 'Automatic download apps purchased on other Macs' working (it's always grey in System Preferences).


com.apple.commerce.plist

AutoUpdateRestartRequired - Install OS X updates

AutoUpdate - Install App updates

com.apple.SoftwareUpdate.plist

AutomaticCheckEnabled - Automatically check for updates

AutomaticDownload - Download Newly available updates in Background

CriticalUpdateInstall - Install System data files & security updates

ConfigDataInstall - Automatically download apps purchased on other Macs ??? <- I can't get this working (it may be wrong)



# TOGGLE ALL ON
# before setting values quit system preferences & stop software update - stops deafults cache breaking 'AutomaticCheckEnabled'
osascript -e "tell application \"System Preferences\" to quit"
sudo softwareupdate --schedule off
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool YES
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload -bool YES
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall -bool YES
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall -bool YES
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool YES
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool NO
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdate -bool YES
# See the results…
open "/System/Library/PreferencePanes/AppStore.prefPane/"
# TOGGLE ALL OFF (auto checking is on to show other prefs are toggled off)
# before setting values quit system preferences & stop software update - stops deafults cache breaking 'AutomaticCheckEnabled'
osascript -e "tell application \"System Preferences\" to quit"
sudo softwareupdate --schedule off
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool YES
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload -bool NO
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall -bool NO
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall -bool NO
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool NO
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdate -bool NO
# See the results…
open "/System/Library/PreferencePanes/AppStore.prefPane/"


Hope it helps someone.

Mar 10, 2015 6:39 PM in response to tetra89

Either dig into the defaults command e.g.

defaults domains

(find the desired 'domain')

defaults read /path/to/desired.plist

(with lots of filtering via grep etc).


Also search around for blogs & sites that list the defaults system 'hacks'… You need to figure out the reverse domain for the app in question, e.g com.apple.Finder.


https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/defaults.1.html

http://secrets.blacktree.com/

http://www.defaults-write.com/

http://osxdaily.com/tag/defaults/


There are also quite a few server admin sites that also deal with this, since users who manage many systems usually want a way to set preferences en masse, or read/ search the scripts that crop up on github…

https://github.com/mathiasbynens/dotfiles/blob/master/.osx

Automatic Updates via Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.