Get the Date Application Last Opened

March 18, 2019 - 1 minute read -
mac jamf

While Jamf Pro is capable of collecting Application Usage data, sometimes we just want to know when an application was last launched. This information is especially helpful when reclaiming unused licenses, or retiring unused software.

To find this, create an Extension Attribute using the Date data type. Then, select Script for the input type and paste in the following snippet. Though Self Service is used here, any application path can be substituted.



if [ ! -e "$APPLICATION_PATH" ]; then
    result="Not Present"

if [ -e "$APPLICATION_PATH" ]; then
    result=`/usr/bin/mdls "$APPLICATION_PATH" | /usr/bin/grep -w "kMDItemLastUsedDate" | /usr/bin/awk '{ print $3 }'`

if [ "$result" == "" ]; then
    result="2001-01-01 01:01:01"

/bin/echo "<result>$result</result>"

Now that we are capturing the date that our application was last launched, we can use this information when scoping our Smart Computer Groups or setting up Advanced Computer Searches.