I am trying to figure out how effective my laptop battery is. Therefore, I woud like to see for how long the battery has been running without AC, since reboot or since AC was plugged in last.

Is this possible? If not, I'll just have to time it manually myself of course.

I'm running Ubuntu 14.

  • what does the command apm says? I know there is also a proc file, cannot remember it. Aug 23, 2017 at 17:52
  • 1
    Rui - I just get No APM support in kernel (does it matter that I just now installed the package?)
    – anaotha
    Aug 23, 2017 at 18:07

2 Answers 2


I think that upower -d can give you some answers, it shows info about the batteries.

Another source of info is /sys/class/power_supply/XX where XX is any battery listed in the folder...

You can see upower official docs to find more info

  • 3
    It doensnt answer my particular question, sadly, but does contain useful info. Thanks anyway:)
    – anaotha
    Aug 24, 2017 at 13:20
  • 3
    In my case, upower -d also outputs info for the AC device. The 'updated:' timestamp is the moment the AC power was either connected or disconnected. On Ubuntu 18.04, it also displays how many seconds ago this was.
    – anneb
    Mar 10, 2020 at 10:45
  • @anneb no it doesn't. It's the last time it was started "in use". Nothing to do with AC being plugged in or not. eg unplug,, run on battery, shut down, restart - the updated is the time it turned back on.
    – RichieHH
    Apr 30, 2021 at 4:40
  • @RichieHH Majority of people I'd say would be calculating the time their computer can run on battery. And in most cases that wouldn't include a reboot (just constant usage). And for that scenario, time update is very relevant. Jul 27, 2021 at 21:36

It's absolutely inexcusable and horrible Linux doesn't have this feature (at least in XFCE/or using any console utilities), so that's how I added it:

# cat /etc/udev/rules.d/99-battery-charging.rules
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/local/bin/battery-logger.sh Plugged-in or charging"

# cat /etc/udev/rules.d/99-battery-discharging.rules
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/local/bin/battery-logger.sh Discharging"

# cat /usr/local/bin/battery-logger.sh
#! /bin/bash

export LANG=en_DK.UTF-8
echo "$(date +"%x %X") $(cat /sys/class/power_supply/BAT0/capacity)% $@" >> /var/log/battery.log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .