Device Model & OS Version
MacBook Pro (16-inch, 2019) Intel
MacOS Monterey 12.0.1 (21A559)
Issue Description
softwareupdate -d -a
softwareupdate -i -a --restart
Commands above "freeze" when they are executed as launchd tasks.
sudo launchctl load -w /Library/LaunchDaemons/com.jamfsoftware.task.runMacOSUpdatesInstalling.plist
<!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>com.jamfsoftware.task.runMacOSUpdatesInstalling</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/softwareupdate</string>
<string>-i</string>
<string>-a</string>
<string>--restart</string>
<string>--force</string>
</array>
<key>StartInterval</key>
<integer>60</integer>
<key>UserName</key>
<string>root</string>
</dict>
</plist>
Issue Root Analysis
If softwareupdate commands are executed through the Terminal shows notifications in the macOS notification center (as shown in the screenshot).
When softwareupdate commands are runned as launchd tasks they are also trying to show notification, but GUI cannot be launched by a daemon in macOS and commands freeze.
Impact on Users
The problems described make it difficult to automate operating system updates using MDM, such as Jamf. This has a negative impact on macOS security management.
Question
Perhaps someone has encountered a similar problem and knows how to execute the above commands by the launchd tasks?