Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to return the current watt consumption on the command line? I have found about the powertop program, but have not seen a way to return the Watt consumption as a value to the command line. I'm thinking of some file that I can cat or grep.

Using Arch Linux.

share|improve this question

3 Answers 3

up vote 10 down vote accepted

On my system I can obtain the power drawn from the battery from

cat /sys/class/power_supply/BAT0/power_now
9616000

The value seems to be in µW, though. You can convert it with any tool you're comfortable with, e.g. awk:

awk '{print $1*10^-6 " W"}' /sys/class/power_supply/BAT0/power_now
9.616 W
share|improve this answer

On a laptop by reading the ACPI data from either procfs or sysfs. On my system the files are:

/proc/acpi/battery/BAT0/state
/sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT0/power_now

Note that the sysfs is heavily symlinked so there are many ways to reach the file. power_now is the file name you are looking for.

share|improve this answer

My laptop has none of these (it also has no battery currently), but it does have a "powercap" device.
It seems this device is able to set restrictions on the user power.

And it (naturally) can read the power draw in order to enforce them.
The power draw can be found at the energy_uj file, i.e.:

cat /sys/class/powercap/*/energy_uj

It'll show the lecture (or lectures, if you have many powercap devices) in micro-Joules. This is actually a counter of the energy consumed, so you need to divide it by a time delta in order to get the power.

Is this the power drawn by my laptop, or just a part of it? I don't know.

share|improve this answer
    
Well, these devices are fairly common on new computers... On all of my tests, at least one of them shows a realistic power draw value with very good precision. I should test with a multimeter, though. –  jmendeth Oct 12 at 9:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.