Last active
August 29, 2015 14:27
-
-
Save cgould/fa7e4e821c68997f3f34 to your computer and use it in GitHub Desktop.
List android running packages with their start time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
uptime=$(adb shell cat /proc/uptime | awk '{print int($1)}' ) | |
apps=$(adb shell pm list packages | sed s/package:// | sed $'s/\x0D//' | awk '{printf "%s\\\|", $0} END {printf "@@@\n"}') | |
adb shell ps | grep `echo $apps` | while read line ; | |
do | |
pid=$(echo -n $line | awk '{print int($2)}') | |
name=$(echo -n $line| awk '{printf "%s", $NF}'| sed $'s/\x0D//') | |
starttime=$(adb shell cat /proc/$pid/stat | awk '{print int($22 / 100)} ') | |
now=$(date +%s) | |
diff=$((now-(uptime-starttime))) | |
diffp=$(date -r $diff) | |
printf "%s - %s\n" "$diffp" "$name" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment