pm-action
Suspend, hibernate, or shutdown the system
SYNOPSIS
pm-action <action> <hook_type>
PARAMETERS
<action>
Defines the power management event that triggered the action:
- suspend: System is suspending to RAM or resuming from it.
- hibernate: System is hibernating to disk or resuming from it.
- resume: Specific for actions taken after resuming from suspend.
- thaw: Specific for actions taken after resuming from hibernate.
- reboot: Indicates a system reboot event.
- force-suspend: Internal variant for forcing suspend.
- force-hibernate: Internal variant for forcing hibernate.
- force-resume: Internal variant for forcing resume.
- force-thaw: Internal variant for forcing thaw.
- suspend-hybrid: Indicates a hybrid suspend (suspend-to-RAM and disk).
<hook_type>
Specifies when the scripts are executed relative to the action:
- pre: Run scripts before the system enters the sleep state.
- post: Run scripts after the system resumes from the sleep state.
- true: Internal signal indicating the preceding sleep action was successful.
- false: Internal signal indicating the preceding sleep action failed.
DESCRIPTION
pm-action is a foundational utility script within the pm-utils package, designed to facilitate custom script execution during system power state transitions. It serves as a hook mechanism, primarily invoked by higher-level power management commands such as pm-suspend and pm-hibernate.
Its core function is to run user-defined scripts located in directories like /etc/pm/sleep.d/ and /usr/lib/pm-utils/sleep.d/. These scripts are executed either before the system enters a low-power state (like suspend or hibernate) or after it resumes. This capability allows system administrators to automate critical tasks, such as unmounting network drives, synchronizing data, or adjusting hardware settings prior to sleep, and re-establishing connections or reloading services upon waking.
While still present in many Linux environments, pm-action and the broader pm-utils framework have largely been superseded by systemd's integrated power management features in modern distributions (e.g., systemctl suspend, systemctl hibernate).
CAVEATS
pm-action is typically called by other pm-utils commands and is not usually invoked directly by users. In modern Linux distributions, power management is primarily handled by systemd, making pm-action less relevant for new configurations. Custom scripts must be executable and placed in the designated sleep directories (/etc/pm/sleep.d/ or /usr/lib/pm-utils/sleep.d/).
SCRIPT EXECUTION ORDER
Scripts within the /etc/pm/sleep.d/ and /usr/lib/pm-utils/sleep.d/ directories are executed in lexical (alphanumeric) order. Each script receives the <action> and <hook_type> as command-line arguments, allowing for conditional logic within the scripts.
IMPACT OF SCRIPT EXIT STATUS
For 'pre' hooks, if any script exits with a non-zero status, pm-action may abort the suspend or hibernate operation, preventing the system from entering the low-power state. This provides a mechanism for scripts to signal critical failures that should halt the sleep process.
HISTORY
pm-action is a component of the pm-utils collection, which emerged as a common framework for managing power states (suspend-to-RAM, suspend-to-disk) on Linux systems. It provided a standardized way for system administrators to integrate custom scripts into the suspend/resume process before systemd became the dominant init system. While its direct usage has declined with systemd's widespread adoption, it remains available on systems where pm-utils is installed, often supporting legacy configurations or environments not utilizing systemd for power management.
SEE ALSO
pm-suspend(8), pm-hibernate(8), systemctl(1), systemd-sleep(8)