Is there a shell command for just Shutdown? - Nexus One Q&A, Help & Troubleshooting

I am doing some testing and writing scripts in GScript and was wondering if there is a power off or shutdown command (as opposed to reboot). I want a command that will literally just turn the phone off but it needs to be a command line command, not an app.
Thanks

Code:
C:\>adb shell
* daemon not running. starting it now *
* daemon started successfully *
# which shutdown
which shutdown
/system/bin/shutdown
http://www.computerhope.com/unix/ushutdow.htm
lol i tried "shutdown -k" and it shutdown my phone!
Code:
# shutdown -k wait
shutdown -k wait
mount: mounting tmpfs on /dev failed: Device or resource busy
mount: mounting sysfs on /sys failed: Device or resource busy
mount: mounting none on /dev/cpuctl failed: Device or resource busy
C:\>

When I try shutdown from terminal it just locks the phone up completely

+1
I too am trying to achieve phone power down using a script. But like you when I issue the shutdown command the phone immediately powers off and won't switch on again without a battery pull.
Same for reboot command.
I am using gscript lite and have s-off with a stock Froyo sense ROM.

"poweroff" generally works in linux systems. I haven't tried this in Android though.

"reboot -p"

GldRush98 said:
"poweroff" generally works in linux systems. I haven't tried this in Android though.
Click to expand...
Click to collapse
Poweroff works if run using busybox, however, the command needs parameters to run.
#poweroff (doesn't work)
#busybox poweroff (also doesn't work)
#busybox poweroff -d 8 -f (works!!)
The -d 8 delays by 8 seconds to give system a chance to stop processes and unmount filesystems, whilst the -f forces poweroff.
Works a treat using Gscript. Not sure if it harms the system as the busybox poweroff command does not use init. That may be a bad thing. I just don't know enough about Android/Linux to know that. Maybe someone else does???

"reboot -p" works.
"busybox poweroff -d 8 -f" works too.
"busybox poweroff -f" works.

If I use the power button to shut down it takes a bit of time, goes through a process. If I shut down using terminal, by the command reboot -p, the shut down is instant. Is there any harm in that, or is that ok to shut down like that?
I like to find ways to reduce the use of the power button, as some have reported it fails after time, but if it's not good for the system then I'll just shut down normally using the power button...

YES! "reboot -p" works for me
duskymagus said:
"reboot -p" works.
"busybox poweroff -d 8 -f" works too.
"busybox poweroff -f" works.
Click to expand...
Click to collapse
YES! "reboot -p" works for me

"reboot -p" has a possibility of harming the phone.

What if none of these commands work for my device?
reboot does work.
reboot -p does not, just returns to command prompt.
shutdown does not work (no such file)
poweroff does not work (no such file)
busybox is installed, but these applets are not installed
Is there any other way?

"adb shell shutdown"
AngelOfGrief said:
What if none of these commands work for my device?
reboot does work.
reboot -p does not, just returns to command prompt.
shutdown does not work (no such file)
poweroff does not work (no such file)
busybox is installed, but these applets are not installed
Is there any other way?
Click to expand...
Click to collapse
If you use adb:
"adb shell shutdown" - performs immediate shutdown

poweroff under su always worked for me.

Nothing works but reboot -p for abrupt shutdown on my phone..

It may cause harm
Bryce2010 said:
If I use the power button to shut down it takes a bit of time, goes through a process. If I shut down using terminal, by the command reboot -p, the shut down is instant. Is there any harm in that, or is that ok to shut down like that?
I like to find ways to reduce the use of the power button, as some have reported it fails after time, but if it's not good for the system then I'll just shut down normally using the power button...
Click to expand...
Click to collapse
Sometimes there are problems when you use reboot -p too often, like failure in file systems because they are not unmounted safely. I do not use this command very often. I only use reboot recovery for flashing roms. Just try not to use this command very often to prevent harm okay?
Current Phone/ROM:
Samsung Galaxy Ace GT-S5830/Cyanogenmod 10.1 RC1 by bieltv3
Recovery:
CWM v5.0.2.6
ROMs used in the past: CM9 RC2 by Maclaw, SGS2 v9 ROM, AOSP ICS ROM by Maclaw, PAC ROM(very disappointed with this, no play store included.)

reboot -p actually does a reboot
Hi there,
on my device
Code:
reboot -p
does shut down the device, but after a few seconds (like 2 or 3 seconds) it boots again. So actually it behaves like doing a normal reboot. Any ideas how I can fix this issue?
Thank you and kind regards,
ToBe_HH

Hello gyus,
is there any Android application to perform power off?
Thank you

The followin shut down my CM13 using the Cerberus shell. Very slick.
su -c 'am broadcast android.intent.action.ACTION_SHUTDOWN && sleep 5 && reboot -p'
from:
android stackexchange com/questions/73001/how-to-shutdown-android-via-ssh-command

gorlox said:
The followin shut down my CM13 using the Cerberus shell. Very slick.
su -c 'am broadcast android.intent.action.ACTION_SHUTDOWN && sleep 5 && reboot -p'
from:
android stackexchange com/questions/73001/how-to-shutdown-android-via-ssh-command
Click to expand...
Click to collapse
works perfectly, also with 'reboot' and 'reboot recovery'

Related

[Q] Need help with recovery mode automation with adb script on computer.

I am making a automated script to compile the latest Cyanogen Mod for milestone and it is working good except for auto updating the phone. I have a couple steps I can't figure out how to automate and one that is not working for some unknown to me reason.
I would like to know adb shell commands that would wipe the cache (I already know dalvik) and apply the update (will have a uniform name that can be hard coded)
Here is just the relevant section of the script with the problem I can't figure out why it wont work.
After rebooting into recovery it never finds the phone again and start the rest of the script
if [ "$1" == "-f" ]
then
echo "Waiting for phone if not connected; connect it"
adb wait-for-device
echo "Pushing update archive to phone"
adb push out/target/product/umts_sholes/update-cm-*-Milestone-signed.zip /sdcard/OpenRecovery/updates/update-cm-latest.zip
echo "Rebooting to recovery mode"
adb reboot recovery
echo "Please hold volume up and hit the camera button then apply update.zip" #Can't be automated
adb wait-for-device #Does not work for some reason
adb shell wipe_dalvik_cache.sh
echo "Please wipe cache and apply update until I find out how to automate"
adb reboot
exit 0
fi

problem rooting my device

Not sure if this is the correct category, but here goes my problem:
I'm following the instructions on wiki.cyanogenmod.com/index.php?title=HTC_Tattoo:_Full_Update_Guide
And now I am stuck at step 7 under Rooting the HTC Tattoo.
The first problem occurs after entering exit:
This line appears repeatedly
usage: reboot [-n] [-p] [rebootcommand]
So I had to close down the command window and start it again. And the next problem appears after entering this line:
while 'true' ; do ./m7 ; done
Same thing again, I have to close the command window and start again. After entering adb shell again I try with entering chown root.root su as it says and this line appear:
chown root.root su
Unable to chmod su: Operation not permitted
Does anyone know what to do from here?
There is a problem with the update guide. Dont follow it, I reported this problem long back in the CyanogenMod forums, but no one corrected it.
Get the 1-click root method with clockworkmod 3.0.0.5 by nTenisOT, its the best rooting option. It also installs clockworkmod recovery.
Also, you could try Universal Androot, but if u root with this, you need to insert the tattoo-hack.ko module before flashing custom recovery manually.
OptimusM said:
Not sure if this is the correct category, but here goes my problem:
I'm following the instructions on wiki.cyanogenmod.com/index.php?title=HTC_Tattoo:_Full_Update_Guide
And now I am stuck at step 7 under Rooting the HTC Tattoo.
The first problem occurs after entering exit:
This line appears repeatedly
usage: reboot [-n] [-p] [rebootcommand]
So I had to close down the command window and start it again. And the next problem appears after entering this line:
while 'true' ; do ./m7 ; done
Same thing again, I have to close the command window and start again. After entering adb shell again I try with entering chown root.root su as it says and this line appear:
chown root.root su
Unable to chmod su: Operation not permitted
Does anyone know what to do from here?
Click to expand...
Click to collapse
hi
pls ask ur question in the rooting thread their are a few threads on the same
CLOSED

[Q] Differences between reboot -p and power btn?

Can anyone tell me the differences btn using reboot -p command and classic way by pressing power button?
reboot -p turns off the phone very quickly, I'm afraid that it's not good for the system
My Galaxy Ace, won't get on after I am execute command reboot -p through adb.
Thats still my big question, how to safely shutdown android through adb shell.

Phone doesn't boot

Hello,
I downloaded the latest version of busybox on my o4x, after I downloaded that, I turned off my device. When I tried to turn it back on, it got stuck on the 'loading apps' page, so I can't basicly do nothing with the phone. I let it load apps for like 10 hours (while on the charger) but that didn't work, and I let my phone run out of battery and after a couple of hours turn it back on, that also didn't work.
Does anyone know how to fix it, or can at least tell me what the problem is?!
Thanks,
Luuk
Try to clear dalvik cache, so that it gets rebuilt. Then try again. If you don't have CWM installed, you might as well be able to do it manually, but unfortunately I don't know the commands for that atm.
luuk.vandeven said:
Hello,
I downloaded the latest version of busybox on my o4x, after I downloaded that, I turned off my device. When I tried to turn it back on, it got stuck on the 'loading apps' page, so I can't basicly do nothing with the phone. I let it load apps for like 10 hours (while on the charger) but that didn't work, and I let my phone run out of battery and after a couple of hours turn it back on, that also didn't work.
Does anyone know how to fix it, or can at least tell me what the problem is?!
Thanks,
Luuk
Click to expand...
Click to collapse
I had the same problem. You can start the P880 in stock recovery and connect it to pc. After the drivers are installed, you have access via adb. Because you installed busybox, i think your device is rooted. So you cann access your P880 with "adb shell", in the shell "su", then you have to mount system and you can push another busybox (e.q. from root, the o4xr directory contains a functionally busybox) to your phone (/system/xbin)
Just download o4xr.zip from the "How to Root" thread.
Then do the following:
- extract o4xr.zip and switch to that folder
- adb shell "su -c 'mount -o remount,rw -t ext4 /dev/block/mmcblk0p33 /system'"
- adb push busybox /sdcard/
- adb shell "su -c 'cat /sdcard/busybox > /data/local/busybox'"
- adb shell "su -c 'chmod 777 /data/local/busybox'"
- adb shell "su -c 'cat /sdcard/busybox > /system/xbin/busybox'"
- adb shell "su -c 'chmod 777 /system/xbin/busybox'"
- At this point the device will reboot itself automatically (Don't know why?), if not: adb shell 'su -c reboot'
- Delete /sdcard/busybox
- Done
I´ve done all this and its booting again with no problems....
Allright, it all sound really complicated to me. I will do my very best! But how exactly do I boot my phone in stock recovery mode, volume up and power button at the same time?
Bogeyof said:
I had the same problem. You can start the P880 in stock recovery and connect it to pc. After the drivers are installed, you have access via adb. Because you installed busybox, i think your device is rooted. So you cann access your P880 with "adb shell", in the shell "su", then you have to mount system and you can push another busybox (e.q. from root, the o4xr directory contains a functionally busybox) to your phone (/system/xbin)
Just download o4xr.zip from the "How to Root" thread.
Then do the following:
- extract o4xr.zip and switch to that folder
- adb shell "su -c 'mount -o remount,rw -t ext4 /dev/block/mmcblk0p33 /system'"
- adb push busybox /sdcard/
- adb shell "su -c 'cat /sdcard/busybox > /data/local/busybox'"
- adb shell "su -c 'chmod 777 /data/local/busybox'"
- adb shell "su -c 'cat /sdcard/busybox > /system/xbin/busybox'"
- adb shell "su -c 'chmod 777 /system/xbin/busybox'"
- At this point the device will reboot itself automatically (Don't know why?), if not: adb shell 'su -c reboot'
- Delete /sdcard/busybox
- Done
I´ve done all this and its booting again with no problems....
Click to expand...
Click to collapse
luuk.vandeven said:
Allright, it all sound really complicated to me. I will do my very best! But how exactly do I boot my phone in stock recovery mode, volume up and power button at the same time?
Click to expand...
Click to collapse
Vol- & Power. Vol+ & Power will bring you to "Emergency mode", this might work as well. Just make sure you have adb access.
Hello
Thanks for the guidance' the only thing is that "adb push busybox /sdcard/" is not recognized so I pushed the file into /temp I created and then continued accordingly
yishay said:
Hello
Thanks for the guidance' the only thing is that "adb push busybox /sdcard/" is not recognized so I pushed the file into /temp I created and then continued accordingly
Click to expand...
Click to collapse
Normally u can push directly through /data/local without the /sdcard step. But its ok to push it to any other local tem-folder before moving it to /system/xbin...
Search for total commander the pc version and the adb plugin then you can access the phone file system, il post what next to do,
* total commander - http://www.ghisler.com/ - officall free version
adb plugin -- http://www.totalcmd.net/plugring/android_adb.html
---------- Post added at 03:53 PM ---------- Previous post was at 03:43 PM ----------
basically what you need to do is said in this extract from a previous post i had done
open total commander and then click configuration and then click options then next click the plugins tab followed by the the WFX button,
then point it at the installed adb plugin,
Once you have done that click the Drive tab in total commander it will be set a drive C:/ and change to Network Neighbourhood, now go to your phone and plug in your usb lead while powering it up and holding the power key and volume up and not releasing until it starts.
Now in total commander click adb in the explorer part and it access you into your phones file system so click on the root folder then click the system folder and then click the Xbin folder i replace the busybox inside with the busybox file which is in o4xr
Please
Hello,
Thanks for the support, but I don't understand anything from your post. I'm not a real geek, and know how all this stuff works, so my phone is still dead. Lg won't take it back for repair, and other phone companies can't manage to fix my phone. So can you please give me some more specific instructions, sorry that i'm a noob, but I miss my phone .
I only understood the 'download the onxr4 file and extract it', after that I lost it:silly:.
Bogeyof said:
I had the same problem. You can start the P880 in stock recovery and connect it to pc. After the drivers are installed, you have access via adb. Because you installed busybox, i think your device is rooted. So you cann access your P880 with "adb shell", in the shell "su", then you have to mount system and you can push another busybox (e.q. from root, the o4xr directory contains a functionally busybox) to your phone (/system/xbin)
Just download o4xr.zip from the "How to Root" thread.
Then do the following:
- extract o4xr.zip and switch to that folder
- adb shell "su -c 'mount -o remount,rw -t ext4 /dev/block/mmcblk0p33 /system'"
- adb push busybox /sdcard/
- adb shell "su -c 'cat /sdcard/busybox > /data/local/busybox'"
- adb shell "su -c 'chmod 777 /data/local/busybox'"
- adb shell "su -c 'cat /sdcard/busybox > /system/xbin/busybox'"
- adb shell "su -c 'chmod 777 /system/xbin/busybox'"
- At this point the device will reboot itself automatically (Don't know why?), if not: adb shell 'su -c reboot'
- Delete /sdcard/busybox
- Done
I´ve done all this and its booting again with no problems....
Click to expand...
Click to collapse
Try reflash the *.KDZ .
See this thread :-
http://forum.xda-developers.com/showthread.php?t=2069723
Then boot into recovery [ (power on) + (vol-) ] .
Then wipe cache ,, and do factory resert . This will delete all your apps .
Good Luck .
Sent From LG-P880
Try Use THANKS Button If I Helped
Kdz flash
luuk.vandeven said:
Hello,
I downloaded the latest version of busybox on my o4x, after I downloaded that, I turned off my device. When I tried to turn it back on, it got stuck on the 'loading apps' page, so I can't basicly do nothing with the phone. I let it load apps for like 10 hours (while on the charger) but that didn't work, and I let my phone run out of battery and after a couple of hours turn it back on, that also didn't work.
Does anyone know how to fix it, or can at least tell me what the problem is?!
Thanks,
Luuk
Click to expand...
Click to collapse
do the kdz flash. Easiest and safest. Worked for me with the same prob like you.
Did that
I already did that al long time ago, didn't work though. I'm considering to buy a new phone, I've been having these prpblems for several weeks now.
OS_Hacking said:
Try reflash the *.KDZ .
See this thread :-
http://forum.xda-developers.com/showthread.php?t=2069723
Then boot into recovery [ (power on) + (vol-) ] .
Then wipe cache ,, and do factory resert . This will delete all your apps .
Good Luck .
Sent From LG-P880
Try Use THANKS Button If I Helped
Click to expand...
Click to collapse
luuk.vandeven said:
I already did that al long time ago, didn't work though. I'm considering to buy a new phone, I've been having these prpblems for several weeks now.
Click to expand...
Click to collapse
Why don't you just send it to LG for repair. They'll fix it for you and you'll get it back as good as new. And after you have done that, stop messing around with busybox.
luuk.vandeven said:
I already did that al long time ago, didn't work though. I'm considering to buy a new phone, I've been having these prpblems for several weeks now.
Click to expand...
Click to collapse
What doy exactly mean? You tried that but didn't work or you are unable to do a kdz flash? Please be clear.
!!
OS_Hacking said:
Try reflash the *.KDZ .
See this thread :-
http://forum.xda-developers.com/showthread.php?t=2069723
Then boot into recovery [ (power on) + (vol-) ] .
Then wipe cache ,, and do factory resert . This will delete all your apps .
Good Luck .
Sent From LG-P880
Try Use THANKS Button If I Helped
Click to expand...
Click to collapse
Dude...
You are my man! I've got the problem solved, so thank you!!

[Q] Booting to recovery with ADB

Good morning guys,
I potentially have a couple of hundred of these to update with an AOSP ROM. I dont have any problems with the update, all smooth sailing, but I'm trying to script as much as possible to automated the process - Unlock bootloader, get root, push all the files then install the ROM.
For some reason though the command 'adb reboot recovery' doesn't work as expected. It just reboots the phone back to the normal OS.
Has anyone else encountered this? or a work around?
I can issue 'adb reboot-bootloader' and it will reboot into the bootloader correctly where I can issue fastboot commands but not to the recovery (Which is CWM latest as of today, which I think is 6.1.1?)
Thanks in advance!
Code:
adb shell
su
echo "boot-recovery" | /system/bin/dd of=/dev/block/mmcblk0p5 bs=1 count=13
reboot / reboot recovery
Adam77Root said:
Code:
adb shell
su
echo "boot-recovery" | /system/bin/dd of=/dev/block/mmcblk0p5 bs=1 count=13
reboot / reboot recovery
Click to expand...
Click to collapse
Your a genius.
As a side note this didn't require root access.
Adam77Root said:
Code:
adb shell
su
echo "boot-recovery" | /system/bin/dd of=/dev/block/mmcblk0p5 bs=1 count=13
reboot / reboot recovery
Click to expand...
Click to collapse
Maybe you can help me out a little futher. What I'm trying to do is automate the superuser install.
From the look of that, is that writing to one of the recovery commands located under /cache/recovery ? Perhaps the command file?
If it is or not, perhaps you know of a way to write the /cache/recover/command file to run an update ZIP immediately on rebooting into the recovery? My reading seems to be going in circles.
From my reading what I would need to do is:
* Copy the superuser.zip to the sdcard
* write 'boot-recovery' to 'a' file as you mentioned above
* write '--update_package=/sdcard/superuser.zip' to the file /cache/recovery/command
Obviously without root already I cant just write to that file so I thought it might be possible to use 'dd' as above?
Then rebooting into recovery should automatically run the update zip? Or am I mad?
You do need root to write into the command file. 'dd' tool also needs root.

Categories

Resources