如何知道系统正常运行时间在电池下?这样我就可以获得准确的电池备份时间,uptime
显示完整的正常运行时间(交流电/电池)
笔记:我使用的是 Linux Mint 17。
答案1
您可以使用 UDEV 获取有关系统电池的详细信息。
连接到电源$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
native-path: /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:0a/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
vendor: Panasonic
model: 42T4801
serial: 624
power supply: yes
updated: Sat Oct 18 13:17:16 2014 (2 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: fully-charged
energy: 80.5788 Wh
energy-empty: 0 Wh
energy-full: 80.9892 Wh
energy-full-design: 84.24 Wh
energy-rate: 0.00372912 W
voltage: 12.224 V
percentage: 99.4933%
capacity: 96.141%
technology: lithium-ion
电池
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
native-path: /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:0a/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
vendor: Panasonic
model: 42T4801
serial: 624
power supply: yes
updated: Sat Oct 18 13:37:36 2014 (22 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
energy: 79.9524 Wh
energy-empty: 0 Wh
energy-full: 80.9892 Wh
energy-full-design: 84.24 Wh
energy-rate: 17.172 W
voltage: 11.94 V
time to empty: 4.7 hours
percentage: 98.7198%
capacity: 96.141%
technology: lithium-ion
History (charge):
1413653856 98.720 discharging
1413653826 98.893 discharging
1413653796 99.080 discharging
1413653766 99.293 discharging
History (rate):
1413653856 17.172 discharging
1413653826 17.399 discharging
1413653796 17.453 discharging
1413653766 17.345 discharging
我从来没有见过任何显示电池消耗时间的东西,所以你必须根据上面的输出来计算它。此外,此输出通常会显示“充电时间”,这是其通电时间的粗略指标。