Auto Mode Power Management
How does the "auto" mode work?
There is a process running, waiting for WoL packets to arrive.
This process can be found as "pwrmgr" in the process list.
In addition to this, there is a script "/usr/local/sbin/pmcd_exec.sh" which uses a feature of the pwrmgr to keep the box alive even if there is no client anymore (e.g. in case of running backups, RAID recovery, running disk format etc.).
How to keep a box alive without a client in "auto" mode?
Sometimes one wants to keep the box alive until a script running on the box finished a long time task.
If the box is running in "auto" mode (means: staying alive until the last client stops sending WoL packets), one just has to call the next line once every 3 minutes to keep the box alive:
pwrmgr -c localhost act
But how to use this, if the long time task takes more than 3 minutes to finish?
Before starting the long time task, create a file in /var/lock/ you can test for existance:
Then start this script as a background task (means: add a " &" when calling the script):
#!/bin/sh while [ -f /var/lock/kenatonline ]; do /usr/local/sbin/pwrmgr -c localhost act sleep 180 done
After the long time task, delete the file:
The box will shutdown automatically within 3 minutes.
Of course this will only work, if the long time task is synchronous itself (means: the long time task is blocking the user input until it has finished).
Is it asynchronous, you have to find the postcondition which is true when the task finished and replace the while condition of the script above (e.g. testing for the process of the long time task).