Page 1 of 1

How to power down via software?

Posted: 22 Mar 2008, 15:42
by csp
Hi,

Is there any way of powering down a bubba by software at a fixed time each day? My initial thought was to put "shutdown -P now" in root's crontab, but that seems to put the machine into single user mode rather than powering off (i.e. I can still ping it!). Using "shutdown -h now" powers off the disk, but leaves the led blinking, and the network card active.

Thanks!
Colin

Posted: 22 Mar 2008, 17:49
by Cheeseboy
Howdy Colin,

I have never tried it in a cron-job, but why not just use "poweroff" instead of shutdown?

Best regards,

Cheeseboy

Posted: 22 Mar 2008, 19:50
by csp
Cheeseboy wrote:I have never tried it in a cron-job, but why not just use "poweroff" instead of shutdown?
That does the same as "shutdown -h": powers down the disk, but leaves the LED blinking and the main power on. I was hoping for something that would turn the machine off totally, like holding down the power button.

Cheers,
Colin

Posted: 22 Mar 2008, 20:00
by Cheeseboy
Hi again,

Do you get the same result if you execute it manually as root?
If not, I'm afraid I'm out of my depth and cannot help you.

/Cheese

Posted: 22 Mar 2008, 20:08
by csp
yeah, it works the same manually :-(

Posted: 22 Mar 2008, 20:17
by Cheeseboy
Weird. Mine shuts down completely.
Perhaps we got different models...

I think this has to go to the Excito staff.

Cheers!

Cheeseboy

Posted: 24 Mar 2008, 11:30
by csp
Following up on this, the web admin script in /usr/lib/web-admin/backend.pl has code to do a shutdown. The relevant part, as a shell script, is as follows:

Code: Select all

#!/bin/sh
MAGIC=/sys/devices/platform/buttons/bubbabuttons0/magic
if [ -e $MAGIC ]; then
        echo 19088743 >> $MAGIC
        /sbin/reboot
else 
        /sbin/poweroff
fi
Running this as a script from root's crontab seems to do a timed shutdown, although it's not exactly elegant.

Posted: 31 Mar 2008, 14:58
by tor
Hi,

I can give some background on how things work.

If you do a shutdown -h or a poweroff Linux inside bubba will try to do a complete shutdown and turn of power. The problem here is that there really is no way to cut power from software on bubba. So Linux will end up in an endless sleep in the end. And this is why leds and such is still enabled.

What happens when you press the powerbutton is that the driver in charge of this writes a "magic" value, 19088743 as csp noted ,in a ram located inside the CPU itself. And then issues a reboot insted.

What happens then is that the bootloader catches this on reboot. And instead of doing a reboot it shuts down the disk and waits for a new buttonpress to restart the system.

/Tor