Remote shutdown using ssh

Discuss about life, love, interests and modding here!
Post Reply
ellnic
Posts: 3
Joined: Sun Feb 17, 2019 12:11 am
Answers: 0
Been thanked: 5 times

#1

Hi,

I’m trying to shutdown my s912 using ssh. This is going to come across as a real n00b question, but it’s not behaving as I would expect. If I issue, for example:

1. poweroff
2. halt -p
3. shutdown -p now
4. reboot -p
5. setprop sys.powerctl shutdown
6. svc power shutdown


The shutdown routine starts, but there’s only a brief flicker of red LED then it turns blue and the box boots again. This isn’t a box or ROM incompatibility issue, as pressing the power button or choosing the shutdown option do indeed behave as expected. The box shuts down and the power light goes red.

What magic wizardry are you calling when the shutdown power menu option is clicked? I need the box to be gracefully shutdown before an automation kills power to the unit.

Thanks :-)


Edit: don’t worry I’ve found it, the magic words are:

Code: Select all

am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN
To take this one step further, if you are using dropbear and have properly setup keys, you can initiate a shutdown as a one liner like this:

Code: Select all

ssh -p 2222 -i keyfile user@ipofbox -t “su -c ‘am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN’”
To easily integrate into automations. Hope this helps others.
Post Reply