Restart android machine

AndroidAdbAndroid Source

Android Problem Overview


we have android + linux m/c, we log in into linux shell and boot the machine in android GUI. now we have the some script that is running on the same machine through linux shell. In that case when the script hangs we need to restart android machine. but it result into restarting the linux machine too. as they are on same machine. so i need the way to restart the android so it comes out of hang state and control remains on the script that is running through the linux shell.

so is there any adb or linux command that work for me?

Android Solutions


Solution 1 - Android

Have you tried simply 'reboot' with adb?

  adb reboot

Also you can run complete shell scripts (e.g. to reboot your emulator) via adb:

 adb shell <command>

The official docs can be found here.

Solution 2 - Android

You can reboot the device by sending the following broadcast:

$ adb shell am broadcast -a android.intent.action.BOOT_COMPLETED

Solution 3 - Android

adb reboot should not reboot your linux box.

But in any case, you can redirect the command to a specific adb device using adb -s <device_id> command , where

Device ID can be obtained from the command adb devices
command in this case is reboot

Solution 4 - Android

I think the only way to do this is to run another machine in parallel and use that machine to issue commands to your android box similar to how you would with a phone. If you have issues with the IP changing you can reserve an ip on your router and have the machine grab that one instead of asking the routers DHCP for one. This way you can ping the machine and figure out if it's done rebooting to continue the script.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSagarView Question on Stackoverflow
Solution 1 - AndroidalexView Answer on Stackoverflow
Solution 2 - AndroiddrindtView Answer on Stackoverflow
Solution 3 - AndroidanishsaneView Answer on Stackoverflow
Solution 4 - AndroidZeroInputCtrlView Answer on Stackoverflow