- Unix Commands Reference
- Unix Commands - Home
apmd Command in Linux
Advanced Power Management Daemon, commonly referred to as apmd is a command used in Linux systems to monitor APM events reported by the driver. These events include changes in the battery level or requests to enter sleep or suspend mode. It works alongside the APM BIOS driver in the OS kernel.
When a specific event occurs, the apmd can execute a command, usually a shell script, and log relevant power status changes using syslogd. Once the battery level drops to a critically low point, it alerts all users on the system.
For regular suspend, the apmd command syncs the data to disk, sleeps briefly, and tells the APM driver to continue. For critical suspend or emergency shutdown, the apmd command only tells the driver to continue. Most uses of this command involve a proxy command specified with -P or in /etc/apm/apmd_proxy for power conservation activities.
Table of Contents
- Syntax for apmd Command in Linux
- Available Options for apmd Command in Linux
- Practical Use of apmd Command
- apmd Files Overview
Syntax for apmd Command in Linux
The basic syntax to use the apmd command on Linux is provided below −
apmd [options]
Here, the apmd keyword will invoke the apm daemon on your system, while options are different flags that can be used to get the desired information.
Available Options for apmd Command in Linux
With the apmd command, you can use different options, such as −
Options | Description |
---|---|
-c seconds or --check seconds | Determines how often apmd checks the status of the APM on your Linux system. You can adjust this value to check your battery levels more or less frequently. |
-P proxy_cmd or --apmd_proxy | Specifies a command to run when a specific APM event occurs on your system. For example, you can set up a script to conserve power once the battery drops low. |
-p perecent_change or --percentage percent_change | Logs information once the battery percentage changes a specified amount. If no value is set, it will take 5% as the default percentage value. It is beneficial for monitoring power fluctuations. |
-V or --version | Prints the APM daemon version |
-v or --verbose | Provides detailed logging of APM events |
-W or --wall | Sends alerts to all users when the battery drops to a critically low point |
-w warn_percent or --warn warn_percent | Logs a warning when the battery percentage goes below a certain level. When you use -W with it, will alert all users |
-q or --quiet | Disables additional warnings. Useful in case the APM BIOS provides audible warnings |
-? or --help | Open help sections to learn about different flags used with the apmd command |
Practical Use of apmd Command
The important use of the apmd command on Linux is to use the proxy commands to support the power conservation activities. You can specify proxy commands on Linux using the -P option. These commands are invoked with one or two arguments, which are given below −
- start
- stop
- suspend [ system | user ]
- standby [ system | user ]
- resume [ suspend | standby | critical ]
- change power
- change battery
- change capability
start
When your computer starts up, the apmd program gets involved. It sets rules for power management across the entire system. For example, it decides when the hard drive should go into standby mode.
These decisions depend on whether the computer is running on battery power or plugged into an outlet.
stop
When you shut down your computer, apmd stops working. It undoes any special settings it made during startup.
suspend [ system | user ]
If your computer goes to sleep (like when you close a laptop), apmd handles it. The BIOS “suspend” mode saves a lot of power by turning off most devices. Laptops can stay suspended using battery power for several days.
standby [ system | user ]
When your computer enters standby mode, it’s like a light nap. The BIOS (the computer’s built-in system) puts most devices to sleep to save power. Standby mode allows the machine to wake up quickly when you need it. However, laptops can’t stay in standby mode for long if they rely solely on battery power.
resume [ suspend | standby | critical ]
When your computer wakes up from standby or other modes, apmd takes action. It knows whether the system was in “suspend” mode (possibly an emergency shutdown) or “standby” mode before. If there was a critical situation, apmd handles that too.
change power
When AC power is added or removed (like plugging/unplugging the charger), apmd pays attention.
It often adjusts the system-wide power policy based on whether the computer is running on battery power.
For example, it might make IDE hard drives enter standby mode more aggressively when only battery power is available.
change battery
If the APM driver detects that one or more batteries are running low, apmd takes note. It assumes there is at least ten minutes of power left. This helps manage the system’s power effectively.
change capability
Sometimes, the system’s power management abilities change, this could happen due to −
- Changes made by a setup utility (like adjusting power settings).
- Arrival or removal of devices (such as connecting or disconnecting hardware).
The daemon (apmd) keeps track of these changes.
apmd issues various log messages, most of which are straightforward and self-explanatory. However, let’s focus on the battery-related messages. When it comes to battery status, the logged information has four fields −
- Rate of Discharge − Negative rates indicate charging.
- Time Since Full Charge/Discharge − Useful if it reflects the time since reaching 100% or 0%.
- Estimated Time Left − Based on recent usage patterns.
- Battery Life Percentage − Estimated by the APM BIOS (usually conservative).
In short, apmd keeps an eye on power changes, device capabilities, and battery status.
apmd Files Overview
There are some files related to apmd, which you can find in your Linux system. These files are −
/dev/apm_bios
This is a special device file that allows communication between apmd and the Linux APM (Advanced Power Management) driver. You can think of it as a channel for apmd to talk to the power management system.
/proc/apm
This one is another important file related to APM that provides status information about the APM driver. You can check things like battery level, power mode, and more using this file.
/etc/apmd_proxy
This file specifies a proxy program that apmd runs if no other proxy is specified. This file specifies a proxy program that apmd runs if no other proxy is specified. The proxy program helps handle power-related tasks. It is like a helper for apmd.
/etc/apm/apmd_proxy (Debian)
Similar to the previous one, but specific to Debian-based systems, this file can also be used as a proxy program by apmd.
Conclusion
apmd plays a vital role in managing power efficiently on Linux systems. From monitoring events to executing proxy commands, it ensures optimal power conservation. In this tutorial, we explained in detail the syntax and several options that you can use with the apmd command. We also supplied several examples to demonstrate the practical use of apmd command.