You are not logged in.

#1 2009-08-26 06:41:46

kalpik
Member
From: India
Registered: 2007-05-08
Posts: 163
Website

Run script just before powerdown after hibernate using pm-hibernate

Hi!

I want to run the apcupsd killpower command just before the CPU powers down after successful hibernate. What it will do, is kill power from the UPS, so that it does not keep the UPS on battery power even after the PC has been shut down. Is there a way to run it during hibernate? Also, it should be the LAST thing to be run before the powerdown event, cause it will instantly kill power from the UPS. Any ideas are welcome. Let me know if i'm not clear enough.

Thanks!

Offline

#2 2009-08-26 11:23:40

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Run script just before powerdown after hibernate using pm-hibernate

Drop a script in /etc/pm/sleep.d/; look in /usr/lib/pm-utils/sleep.d/ for examples on how the script should be written.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#3 2009-08-26 11:44:37

kalpik
Member
From: India
Registered: 2007-05-08
Posts: 163
Website

Re: Run script just before powerdown after hibernate using pm-hibernate

Thanks! But how do i ensure that this is the last thing to be run?

Offline

#4 2009-08-26 11:46:56

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Run script just before powerdown after hibernate using pm-hibernate

Look at the numbers... They go from 00 to 99. Should be a hint wink.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#5 2009-08-26 11:49:12

kalpik
Member
From: India
Registered: 2007-05-08
Posts: 163
Website

Re: Run script just before powerdown after hibernate using pm-hibernate

Yeah.. I figured that much! But if i run the command using 99, would that be the absolute final thing before the CPU shuts down? Cause the command i intend to run, will instantly cut power to the CPU! If there is anything else that needs to be done after i run the script, that wont happen!

Offline

#6 2009-08-26 12:44:29

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: Run script just before powerdown after hibernate using pm-hibernate

kalpik wrote:

But if i run the command using 99, would that be the absolute final thing before the CPU shuts down?

No I think there's further stuff going on afterwards. At a minimum, pm-tools receives the exit code from that script and logs it. I think that then it tells the kernel actually to suspend.

If your UPS is your sole source of power, and there's no battery in the machine, then I don't think you can do what you want with a script in /etc/pm/sleep.d.

Offline

#7 2009-08-26 14:05:55

kalpik
Member
From: India
Registered: 2007-05-08
Posts: 163
Website

Re: Run script just before powerdown after hibernate using pm-hibernate

I was assuming the same! If i shutdown, i could add the command to rc.shutdown.. I was just wanting to know if there's any such file for hibernate..

Offline

#8 2009-08-26 15:58:01

kalpik
Member
From: India
Registered: 2007-05-08
Posts: 163
Website

Re: Run script just before powerdown after hibernate using pm-hibernate

Ohk.. I checked.. The UPS gives about 1 minute grace after the command before shutting down.. So the 99 script works! Thanks a lot guys! Ill update the wiki.

Offline

Board footer

Powered by FluxBB