0

I have two utility applications. I would like to detect which of these was run most recently. My initial idea was to use stat to check the access timestamp on the application files and then compare:

mac:~ user$ stat -qf '%a %N' '/Applications/my-app1.app' '/Applications/my-app2.app' | sort -nr | head -n1 | cut -d ' ' -f2-
/Applications/my-app2.app
mac:~ user$ 

However this is insufficient, because there are other reasons these apps are being accessed - I assume by the backup system I am using.

Are there any system logs that I can examine to determine which of these apps was started most recently?

1

I'm not sure if this will suit your needs, but you could just look at the Recent Applications item stack located at the bottom right end of your Dock (assuming your Dock is located at the bottom of your screen).

If you don't have this stack visible in your dock, follow these steps:

  • Open Terminal (usually located in Applications > Utilities)
  • Type (or copy and paste) the following:

    defaults write com.apple.dock persistent-others -array-add '{"tile-data" = {"list-type" = 1;}; "tile-type" = "recents-tile";}'; killall Dock
    
  • Press the Return key

  • The Dock will quit and relaunch

  • You should now see a new item stack with recently used applications (at left of the Trash can)

  • Clicking on this will display your most recent apps

  • You can right-click (or control-click) on the icon to change what is displayed and how it is displayed. For example, choosing to display it as a List will show the most recent app at the top, and choosing the Grid option will display the most recent app at top left, and so on.

Regardless, the advantage of this over the Apple > Recent Items option is that everything is listed in the order they were run/accessed, instead of being listed in alphabetical order.

  • @klanomath Thanks for the edit. :) For some reason I just couldn't get the code sample to work properly. – Monomeeth Dec 1 '16 at 7:20
  • ;-) I make the same experience in Google Chrome (maybe twice a month) that formatting my answer properly simply doesn't work here. Usually I save the edit, close the tab or relaunch Chrome, reopen the answer and then it works. – klanomath Dec 1 '16 at 7:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .