Search code examples
androidadb

Get last modification timestamp of a file using ADB


Is there a way to access the last modified time of a file on an Android device using ADB, without installing anything on the device? adb shell ls -l <path> gives only minute precision, and adb's version of ls doesn't have --time-style (at least in the current latest version). pull -a preserves the timestamp, but the reason I want the timestamp in the first place is to check whether it needs to be pulled.


Solution

  • You can use the stat utility to get information about a file.

    Run this from the terminal and replace PATH_TO_FILE the the absolute path of the file on the device/emulator that you are trying to get the last modified time for. It should print it to the console.

    adb shell stat -c %y PATH_TO_FILE