Category filter

Script to view the last opened time of apps/files on macOS

This document helps administrators fetch the last opened time of apps or files from macOS devices.

Administrators have to identify when apps or files were last accessed on the device for various reasons. Managing resource-intensive modern apps is crucial for optimizing system performance. A rise in the number of apps on the device can have significant impacts like system slowdown or increased boot times. Also, monitoring the app access behavior on the device makes it easier to draw usage patterns, especially during work hours. Based on the conclusions outlined, admins may choose to uninstall unnecessary apps, freeing up space and improving efficiency. On the other hand, keeping track of the last opened time of files can contribute to basic device/user logging. Admins can execute the scripts given below to find out when an app was last opened using Hexnode UEM’s Execute Custom Script action for Macs.

Scripting language – Bash

File extension – .sh


The sample scripts provided below are adapted from third-party open-source sites.

Fetch the timestamp when the app/file was last opened

You can deploy the following script to fetch the timestamp of an app or file.

As an argument in the Arguments field while deploying the script, provide the file path for the app or file whose last opened timestamp you want to fetch.

Specify app path as an argument as you execute the script to view the last opened time of a macOS app

The output obtained provides the last opened timestamp, both according to UTC and the device’s local time.

Find the last opened time of macOS apps from the Output tab after script execution


  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository