jagdpanzer jagdpanzer - 3 months ago 17
Bash Question

Does starting the adb shell take a lot of resources?

I use a bash script to automate processes on Android devices in my office. I call the shell like this in the script: (Let the

...
stand for any amount of adb shell commands.)

#!/bin/bash

...

adb shell do stuff
adb shell do stuff
adb shell do stuff

...

exit


These scripts function very well. I have already done research on sending multiple commands to a single instance of shell; I'm wondering if they are as efficient as they can be though. Am I using a lot of system resources? Could this potentially raise issues in the future when I'll be running very very large automation scripts using this process?

Answer

Starting of the new sh process does not take a lot of time or resources. Queuing multiple commands to the same sh instance does not provide any noticeable performance improvement. Just be mindful of what commands you run in those shell sessions. Some commands like input are not native binaries but java applications which take longer time to start - so do not expect to be able to fire multiples of those per second.