PDA

View Full Version : Shutdown/Reboot power failure


Yaso
05-24-2002, 09:42 AM
In case of a power failure, I would like to have a command where I can tell my OS X, via SSH, to shutdown now and reboot in 20 mins.

% shutdown -h HHMM
% reboot

Combination of both.

And, I don't now if I'm dreaming, but if in 20 min, no power is available, it will try in another 20 min.

Thanks.

ashevin
05-24-2002, 10:28 AM
Umm... Once you shutdown, how can it possibly reboot? I'm definitely missing something here...

- Avi

Yaso
05-24-2002, 10:41 AM
Same question to you:

How does Apple achieve to restart your Mac after a power failure! Check Pref/EnergySaver/Options tab...

I run an OS X Client as an FTP server. This connect to a APC UPS. I have 15 min to shutdown this machine before the juice goes down. I do that with my laptop via SSH. So I run "% shutdown now" and the server shutdown properly. But how can I restart this server if I'm 100 miles away?

Hope this make it's clearer. Sorry my english is not that good also...

ashevin
05-24-2002, 10:56 AM
OK, now I understand what you are referring to...

Modern PCs don't have a physical off switch anymore. Instead the power button sends a signal to the power supply, via the Mainboard, that it should start/stop providing power. Macs have actually been doing this for far longer than PCs, if not forever. I'm not a Mac guru, so I can't say for sure.

Usually, when power is cut, the default mode of the hardware is to wait for a signal (the power button) before powering up after power is restored. Apple has simply provided a way to change this default behavior. In any case, the PC is not on when there is no power, and the reboot is entirely controlled by the hardware, and in this instance, a setting in firmware to have it power on.

Another way to put this is that the computer is like your tv. When you power off, you are really putting it in a standby mode. Everything is shutdown except for a few pieces of input. Keyboard (on PCs at least), the power button itself, and NIC, if you have wakeup-on-lan. The modem too, on Macs.

In short, there's no way that I know of to schedule a reboot, because it's entirely controlled in hardware.

- Avi

Yaso
05-24-2002, 11:33 AM
Damn!

I guess I'll have to by an Xserve and using DB-9 connector to wake it up!

Thanks for the effort. :)

bakaDeshi
05-28-2002, 04:38 AM
Actually, if you get the XServe it should have fault tolerance built in. It should handle rebooting itself in case of power failures. I don't know of the specifics or if there's any limitations but it has it. maybe apple has some specific specs on it? The current crop of OSX Servers may have it as well but only if you buy the hardware.

sunshineknox
05-03-2005, 01:29 PM
here is the answer to everyone's question
systemsetup -getwaitforstartupafterpowerfailure — to get the number of seconds after which the computer will start up after a power failure.

systemsetup -setwaitforstartupafterpowerfailure <seconds> — to set the number of seconds after which the computer will start up after a power failure, where <seconds> must be a multiple of 30 seconds.

and you can do it in the energy saver pane of system preferences

pasu666
09-01-2007, 02:59 PM
This is what would like to do. Shut of the computer normally. Cut the power.
When the power comes back it should start up without having to press the startbutton.

Is this pssible to achieve in any way?

baf
09-01-2007, 04:23 PM
Possibly this might work
In terminal.app
pmset -g
check what it says for autorestart.
If it is 0 you can try to do:
sudo pmset autorestart 1
It will ask for your password. Give it and then try.....
sudo pmset autorestart 0
resets it to off if it didn't help.
Good Luck.

pasu666
09-01-2007, 05:33 PM
Did not work. Thanks anyway. Anything is worth a try. How does the system now that is a failure. Oh, i think i forgot to set the preferences right. I will try it again. Back soon.

pasu666
09-02-2007, 07:30 AM
Nope, did not work. Let us wait and see if someone comes along with an answer or solution.

acme.mail.order
09-02-2007, 08:16 AM
This is what would like to do.
-Shut of the computer normally.
-Cut the power.

This is possibly what's tripping you up. "Restart after power failure" will not do that after a proper shutdown. You did, after all, tell it to turn off. So you're either going to have to let it get cut off in order for the restart function to work, or do some deeper tinkering.

If you are trying to script a server power failure solution with a UPS, you could use the impending failure warning from the UPS to shut down all services - turn off Apache, Ftpd, Mail server, log out the desktop etc. Take it right down to the bare minimum. If it's not active when the power gets cut the chance of a disk failure is very, very small.

pasu666
09-02-2007, 04:42 PM
This is possibly what's tripping you up. "Restart after power failure" will not do that after a proper shutdown. You did, after all, tell it to turn off. So you're either going to have to let it get cut off in order for the restart function to work, or do some deeper tinkering.


"Restart after power failure" will not do that after a proper shutdown. You did, after all, tell it to turn off. Exactly, but how do tell or make the system think there is power failure after a normal shutdown followed by a power cut.

Apparently the system/hardware recognizes a power cut when the system is running and restarts it when power comes back. So if every normal shutdown is "made" to be a power failure it would restart immediatly. By tweaking the time before it restarts when power comes back as someone said erlier in this thread, you would give yourself some time to cut the power before it restarts.

And then next time power is given back it will wait the stated time and then restart.

Possible?

acme.mail.order
09-02-2007, 10:25 PM
The system will send a signal to the power supply commanding a shutdown when you do things normally. The power supply is built to take it's startup trigger from power application rather than the power button if this signal is not sent. It's possible, but you are going to have to hack the kernel code to do it. This means reading tons of documentation, downloading the Darwin source and studying it for a while.

Something wrong with my suggestion of reducing your system to the minimum and waiting for the lights to go out? A LOT less work.