How do I observe and control a macOS update using `softwareupdate`?

I made the mistake (don't ask) of entering

softwareupdate -ia --verbose

in Terminal, which is now stuck doing — I don't know what:

Software Update Tool

Finding available software

Downloading Command Line Tools (macOS Mojave version 10.14) for Xcode
Downloading macOS 10.14.4 Update
Downloaded Command Line Tools (macOS Mojave version 10.14) for Xcode
Downloaded macOS 10.14.4 Update
Installing Command Line Tools (macOS Mojave version 10.14) for Xcode, macOS 10.14.4 Update
Done with Command Line Tools (macOS Mojave version 10.14) for Xcode

and attempts to stop it with ^C result in

Cannot cancel updates after installation has started.

I have no progress indictor or feedback, and this has been going on for hours and softwareupdate --dump-state shows no entries (except for running dump-state) for quite some time.

How do I check the status of a softwareupdate installation, and how do I abort it if it isn't stopping or completing on its own?


Solution 1:

Out of frustration I simply tried

softwareupdate --install --all

in a new Terminal window, which unstuck the instance of softwareupdate running on the other original window. This seems to have resolved the issue completely.

Solution 2:

You can observe the progress softwareupdate is making by viewing its logging messages.

Just run sudo log stream --predicate "processImagePath Contains[c] 'softwareupdate'" in another terminal to view the log messages live. Or look at logged messages during the last 10 minutes by using sudo log show --last 10m --predicate...

Its logging is quite noisy, but some of these relay the current progress. There's a separate progress counter both for the software download, and the install.

For example, while in the install phase I see messages like this:

$ sudo log stream --predicate "processImagePath Contains[c] 'softwareupdate'"
2020-10-23 16:41:50.036577-0700 0x10343ce  Default     0x0                  1495   0    softwareupdated: (BridgeOSSoftwareUpdate) [com.apple.BridgeOSSoftwareUpdate:] -[BridgeOSSoftwareUpdateController _handleEvent:]: received progress: PrepareUpdate = 6.650325
2020-10-23 16:41:50.036650-0700 0x1033b05  Default     0x0                  1495   30   softwareupdated: (BridgeOSInstall) [com.apple.mac.install:BridgeOSInstall] Preparing update progress: 6.65
2020-10-23 16:41:51.369927-0700 0x1033b05  Default     0x0                  1495   0    softwareupdated: (BridgeOSSoftwareUpdate) [com.apple.BridgeOSSoftwareUpdate:] -[BridgeOSSoftwareUpdateController _handleEvent:]: received progress: PrepareUpdate = 6.957522
2020-10-23 16:41:51.370001-0700 0x10343ce  Default     0x0                  1495   30   softwareupdated: (BridgeOSInstall) [com.apple.mac.install:BridgeOSInstall] Preparing update progress: 6.96
2020-10-23 16:41:54.500204-0700 0x10343ce  Default     0x0                  1495   0    softwareupdated: (BridgeOSSoftwareUpdate) [com.apple.BridgeOSSoftwareUpdate:] -[BridgeOSSoftwareUpdateController _handleEvent:]: received progress: PrepareUpdate = 6.957528
2020-10-23 16:41:54.500280-0700 0x1033b05  Default     0x0                  1495   30   softwareupdated: (BridgeOSInstall) [com.apple.mac.install:BridgeOSInstall] Preparing update progress: 6.96
2020-10-23 16:41:55.501118-0700 0x1033b05  Default     0x0                  1495   0    softwareupdated: (BridgeOSSoftwareUpdate) [com.apple.BridgeOSSoftwareUpdate:] -[BridgeOSSoftwareUpdateController _handleEvent:]: received progress: PrepareUpdate = 7.303767
2020-10-23 16:41:55.501181-0700 0x1033b05  Default     0x0                  1495   30   softwareupdated: (BridgeOSInstall) [com.apple.mac.install:BridgeOSInstall] Preparing update progress: 7.30
2020-10-23 16:41:56.615577-0700 0x10343c2  Default     0x0                  1495   0    softwareupdated: (BridgeOSSoftwareUpdate) [com.apple.BridgeOSSoftwareUpdate:] -[BridgeOSSoftwareUpdateController _handleEvent:]: received progress: PrepareUpdate = 87.186295
2020-10-23 16:41:56.615655-0700 0x10343c2  Default     0x0                  1495   30   softwareupdated: (BridgeOSInstall) [com.apple.mac.install:BridgeOSInstall] Preparing update progress: 87.19
2020-10-23 16:41:57.964143-0700 0x1033b05  Default     0x0                  1495   0    softwareupdated: (BridgeOSSoftwareUpdate) [com.apple.BridgeOSSoftwareUpdate:] -[BridgeOSSoftwareUpdateController _handleEvent:]: received progress: PrepareUpdate = 91.111293
2020-10-23 16:41:57.964214-0700 0x10343c2  Default     0x0                  1495   30   softwareupdated: (BridgeOSInstall) [com.apple.mac.install:BridgeOSInstall] Preparing update progress: 91.11

Or try a command like this: sudo log stream --predicate "processImagePath Contains[c] 'softwareupdate' AND eventMessage Contains[c] 'progress'", which will filter the log messages to only include ones that contain the string 'progress'

Also for reference, after running softwareupdate --dump-state you can see the information it dumps in /var/log/install.log.