Skip to content

Instantly share code, notes, and snippets.

@wesleyit
Created September 26, 2014 20:58
Show Gist options
  • Save wesleyit/bf6558b6653d702ad33d to your computer and use it in GitHub Desktop.
Save wesleyit/bf6558b6653d702ad33d to your computer and use it in GitHub Desktop.
Run this script to capture the logs of all Android devices connected via ADB.
#!/bin/bash
# ##########################################################
# logcatch_them_all.sh
# Run this script to capture the logs of all Android
# devices connected via ADB.
# Wesley Rodrigues da Silva <wesley.it at gmail.com>
# LICENCE CREATIVE COMMONS BY - 2014
# http://creativecommons.org/licenses/by/2.0/legalcode
# ########################################################
## If running inside Jenkins, will use the default
# workspace, else, will create a folder in /tmp.
if [ -z "$WORKSPACE" ]
then
export WORKSPACE="/tmp/logcat/"
mkdir -p "$WORKSPACE"
fi
## List all adb devices and get each log in a file with
# the device name.
for device in $(adb devices | grep "device$" | cut -f 1)
do
mkdir -p "$WORKSPACE/logcats/" &> /dev/null
adb -s "$device" logcat -d > "$WORKSPACE/logcats/$device.log"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment