Skip to content

Instantly share code, notes, and snippets.

@mikehardy
Created August 31, 2018 18:50
Show Gist options
  • Save mikehardy/e3702d4c46764d726475ee2058bb0f98 to your computer and use it in GitHub Desktop.
Save mikehardy/e3702d4c46764d726475ee2058bb0f98 to your computer and use it in GitHub Desktop.
Android emulator fleet management - shutdown
#!/bin/bash
# I was having trouble with ADB daemon startup, this hack seems to work though it's terrible
adb devices -l > /dev/null
sleep 2
adb devices -l > /dev/null
sleep 2
# Try the nice way
for EMU_ID in `adb devices -l | grep emulator | cut -d' ' -f1`; do
echo Stopping emulator $EMU_ID...
adb -s $EMU_ID emu kill
done
# This would be the brutal way
#for PID in `ps -eo pid,cmd,args |grep emulator|grep Android|grep -v bash|grep -v crash|grep -v grep|cut -d/ -f1`; do
# echo "Stopping emulator with $PID..."
# kill $PID
#done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment