I am downloading Mountain Lion, I know I can monitor download progress through the Mac App Store purchases screen but I want to know if I can monitor progress through Terminal.app using a shell command.
-
2I may have misunderstood the question but is it not much easier to just click on the Purchases "tab" in App Store and watch the progress bar?– user25765Commented Jul 25, 2012 at 20:44
-
I know you can do it in the Purchases tab. I wanted to know if it could be done in the Terminal– conorgriffinCommented Jul 26, 2012 at 13:21
3 Answers
Sure - the storeagent uses a folder deep within /private/var/folders to hold the download progress.
On my Mac it's downloading to this folder below - yours may change, but you should be able to search for the com.apple.appstore using mdfind
and use du
or ls
to see the file size grow.
/private/var/folders/tv/xyw2rpln7hq4gw2m0prg_src0000gn/C/com.apple.appstore/497799835
The App Store has a nicer wrapper on the progress with a time estimate, but with bc
and other tools, you could do the same in a short shell script exercise.
If you can't locate your folder, this find
command might be of use to narrow down your search....
sudo find /var/folders -type d -name com.apple.appstore -print
-
1Could you expand your answer to explain how to find the right directory? Commented Jul 25, 2012 at 18:46
-
Sure - I just did a brute force search based on last modified time and ls - but I'll edit in a
find
command that worked for me...– bmike ♦Commented Jul 25, 2012 at 18:50 -
5
du -h /private/var/folders/*/*/C/com.apple.appstore/*/*.pkg
would print the size of the download in a human-readable format. The total size of the version I'm currently downloading is shown as 4.3 GB in App Store.– LriCommented Jul 25, 2012 at 21:44
I decided that the best way to identify the file being downloaded was to write a small script that fetched the files held open by the App Store program storeagen
.
#!/bin/bash
appstore_pid=$(ps -ef|grep storeagen|grep -v grep|awk '{print $2}')
lsof -p $appstore_pid|grep private|awk '{print $7 "\t" $9}'
I set appstore_pid
variable to the PID of storeagen
by extracting it from the ps
command using grep
and awk
Then I use lsof
to list open files by the PID of storeagen
and I print out the size of the files and the files path. If you do this several times in succession you can see the file(s) that's growing and make a good guess by its size that it is the OS download.
-
Nice use of lsof ;-) I piped to a second
grep
for pkg since I've seen thelsof
return four or more items in /private/var/...– bmike ♦Commented Jul 25, 2012 at 21:06
I just used the activity monitor and watched how much data transfer was happening... And ensure no other traffic at the time of download. Its not perfect, but gives you a general idea something is happening.