LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Batch Script to shutdown the system in the event of power loss (https://www.linuxquestions.org/questions/linux-hardware-18/batch-script-to-shutdown-the-system-in-the-event-of-power-loss-49468/)

scottpioso 03-12-2003 12:39 PM

Batch Script to shutdown the system in the event of power loss
 
Does anyone have any knowledge of whether it's possible to write a shell or batch script to shutdown the system in the event of a power loss? I'm considering a UPS but have not bought one yet. However, I do have important data on this server that I would not want to lose if I lose AC power.

Any ideas would be appreciated. Thank you

Scott

JimKyle 03-12-2003 12:50 PM

I'm using a UPS that includes a serial port, together with a driver that receives the signal from the UPS whenever it switches to battery power. It's configured to do a shutdown 5 minutes after the switch, unless power comes back up during that time. The delay allows for momentary power glitches without forcing shutdown, and the UPS is sturdy enough to keep the box going for at least 15 minutes so there's time for the shutdown.

I've tested it by pulling the plug on the UPS, and it works perfectly. Be sure, though, when you get your UPS to make certain it has the port to notify the computer! My first two did not have this capability. Since then I've learned to look for it (I only have six UPSes scattered around my LAN; only the one on the file server is set up to guarantee proper shutdown)...

michaelk 03-12-2003 01:35 PM

You would need a service that works in the background.

I suggest APC. From what I have see the new ones have a USB port but you can write to them for a serial port adaptor cable.

The linux version of powerchute (shutdown application) only works with the serial port.

Here is another source for a shutdown application. Don't know if it works with the new APC's or not.
http://www.sibbald.com/apcupsd/

scottpioso 03-12-2003 01:41 PM

Thanks!! I presume when you buy it, the device has instructions on how to set it up to work with your server to shut it down in the event of power loss, correct?

michaelk 03-12-2003 03:14 PM

Its been awhile i.e. 5-6 years since I bought mine so I can't say if they include any instructions for linux. If the linux version isn't included on the CD you can download it from APC's website.

JimKyle 03-12-2003 03:40 PM

I didn't get any Linux instructions on the CDs with mine, just Win32. However the APC site has the Linux drivers and they work with non-APC systems also. Most all the trigger circuits seem to be standardized!

A Google search also took me to a site that had instructions for adding a trigger output to a UPS that didn't have one already, but it was easier to just use one that came from the factory complete...


All times are GMT -5. The time now is 02:19 AM.