Hibernation is a great feature on any computer (be it laptop especially, workstation or even server). It allows for a temporary pause in execution in which the system in question can be unplugged, cleaned, modified, or moved.

Hibernation is even handy-er on power failures, where the UPS provides a grace period of the system to go to sleep, only to wake up once the power resumes.

But what happens when some services don’t play nice and fail to resume properly from sleep? What happens when these services run on an unmonitored server, and those services are needed to always run (except when the power goes out)?

Fortunately, Linux’s power management utilities provide the necessary functionality to control services/processes/actions depending on the power state of the system.

Create the following file and make it executable by everyone:

touch /etc/pm/sleep.d/00_powerhandler
chmod 755 /etc/pm/sleep.d/00_powerhandler

Then paste the following content in it and adjust to your needs:

You can check the /var/log/powerhandler.log logfile after a hibernation/wake session to monitor things out.

 

Leave a Reply