Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Like most users that have searched know, Manufacturers ACPI implementation is a mess and for most of our laptops, battery info is unavailable or wrong (on a dell inspiron 15z, the rate is divided by 10).

Is there a way (using a perl/python/bash script, an existing package or whatever) to log battery cycles on Ubuntu 12.04?

(what is a battery cycle ?)

A charge cycle means using all of the battery’s power, but that doesn’t necessarily mean a single charge. For instance, you could listen to your [device] for a few hours one day, using half its power, and then recharge it fully. If you did the same thing the next day, it would count as one charge cycle, not two, so you may take several days to complete a cycle. Each time you complete a charge cycle, it diminishes battery capacity slightly, but you can put [device battery] through many charge cycles before they will only hold 80% of original battery capacity. Apple courtesy

My laptop is a Clevo W150HRM, and when I do : cat /sys/class/power_supply/BAT0/cycle_count I get: 0 My laptop is 2 years old.

Thank you by advance.

share|improve this question
counters are not hard. what data can you use to count? –  Grant Bowman Apr 24 at 13:09
Of course counters are hard ! They're stored on the battery firmware. (Yes, batteries DO have firmwares) –  Bahaïka Jun 11 at 23:15

1 Answer 1

I've just looked into your question... so it might be too late to answer you since it's been years you've posted it.

You are using a rather old ubuntu that is known/was known at that time to have trouble in that specific domain.

However I encourage you to see this question : How to check battery status using terminal?

The answer of Lekensteyn is the start of what you are looking for.

As you can see in the answer the matter evolves along the kernel version and so the solution ...

To be more specific and retaking your conditions (get status and ubuntu 12.04), you need upower in your system and can create a script like :

DATE=$(date +%Y-%m-%d:%H:%M:%S)
STATE=$(upower -i /sys/class/power_supply/BAT0 | awk '/state/ {print $2}')
echo "$DATE $STATE" >> /var/log/battery_status.log

Then add it in a monitoring process loop ... or a crontab.

It might need root privilege (sudo)

Hope this helps.

share|improve this answer

Your Answer


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.