# contents of battery.txt . I removed the AC plug and started the script start Seg Out 19 00:00:22 BRST 2009 Battery 1: charged, 100% Seg Out 19 00:01:22 BRST 2009 Battery 1: discharging, 98%, 01:58:22 remaining Seg Out 19 00:02:22 BRST 2009 Battery 1: discharging, 97%, 01:34:33 remaining Seg Out 19 00:03:22 BRST 2009 Battery 1: discharging, 96%, 01:56:23 remaining Seg Out 19 00:04:22 BRST 2009 Battery 1: discharging, 95%, 01:51:19 remaining Seg Out 19 00:05:22 BRST 2009 Battery 1: discharging, 94%, 01:48:14 remaining Seg Out 19 00:06:22 BRST 2009 Battery 1: discharging, 93%, 01:51:50 remaining Seg Out 19 00:07:22 BRST 2009 Battery 1: discharging, 92%, 01:41:49 remaining Seg Out 19 00:08:22 BRST 2009 Battery 1: discharging, 91%, 01:43:47 remaining Seg Out 19 00:09:22 BRST 2009 Battery 1: discharging, 90%, 01:37:15 remaining Seg Out 19 00:10:22 BRST 2009 Battery 1: discharging, 89%, 01:34:37 remaining Seg Out 19 00:11:22 BRST 2009 Battery 1: discharging, 88%, 01:39:25 remaining Seg Out 19 00:12:22 BRST 2009 Battery 1: discharging, 87%, 01:39:24 remaining Seg Out 19 00:13:22 BRST 2009 Battery 1: discharging, 86%, 01:41:27 remaining Seg Out 19 00:14:22 BRST 2009 Battery 1: discharging, 86%, 01:38:22 remaining Seg Out 19 00:15:22 BRST 2009 Battery 1: discharging, 85%, 01:36:41 remaining Seg Out 19 00:16:22 BRST 2009 Battery 1: discharging, 84%, 01:28:19 remaining Seg Out 19 00:17:22 BRST 2009 Battery 1: discharging, 83%, 01:34:30 remaining Seg Out 19 00:18:22 BRST 2009 Battery 1: discharging, 82%, 01:34:14 remaining Seg Out 19 00:19:22 BRST 2009 Battery 1: discharging, 81%, 01:32:49 remaining Seg Out 19 00:20:22 BRST 2009 Battery 1: discharging, 80%, 01:32:51 remaining Seg Out 19 00:21:22 BRST 2009 Battery 1: discharging, 79%, 01:28:38 remaining Seg Out 19 00:22:22 BRST 2009 Battery 1: discharging, 78%, 01:30:43 remaining Seg Out 19 00:23:22 BRST 2009 Battery 1: discharging, 77%, 01:29:01 remaining Seg Out 19 00:24:22 BRST 2009 Battery 1: discharging, 76%, 01:28:07 remaining Seg Out 19 00:25:23 BRST 2009 Battery 1: discharging, 75%, 01:26:47 remaining Seg Out 19 00:26:23 BRST 2009 Battery 1: discharging, 74%, 01:21:07 remaining Seg Out 19 00:27:23 BRST 2009 Battery 1: discharging, 74%, 01:20:57 remaining Seg Out 19 00:28:23 BRST 2009 Battery 1: discharging, 73%, 01:24:13 remaining Seg Out 19 00:29:23 BRST 2009 Battery 1: discharging, 72%, 01:22:05 remaining Seg Out 19 00:30:23 BRST 2009 Battery 1: discharging, 71%, 01:18:35 remaining Seg Out 19 00:31:23 BRST 2009 Battery 1: discharging, 70%, 01:18:10 remaining Seg Out 19 00:32:23 BRST 2009 Battery 1: discharging, 69%, 01:20:03 remaining Seg Out 19 00:33:23 BRST 2009 Battery 1: discharging, 68%, 01:02:24 remaining Seg Out 19 00:34:23 BRST 2009 Battery 1: discharging, 67%, 01:16:06 remaining Seg Out 19 00:35:23 BRST 2009 Battery 1: discharging, 66%, 01:15:25 remaining Seg Out 19 00:36:23 BRST 2009 Battery 1: discharging, 65%, 01:11:21 remaining Seg Out 19 00:37:23 BRST 2009 Battery 1: discharging, 65%, 01:52:59 remaining Seg Out 19 00:38:23 BRST 2009 Battery 1: discharging, 64%, 01:51:40 remaining Seg Out 19 00:39:23 BRST 2009 Battery 1: discharging, 63%, 01:47:24 remaining Seg Out 19 00:40:23 BRST 2009 Battery 1: discharging, 63%, 01:45:28 remaining Seg Out 19 00:41:23 BRST 2009 Battery 1: discharging, 62%, 01:49:21 remaining Seg Out 19 00:42:23 BRST 2009 Battery 1: discharging, 62%, 01:48:55 remaining Seg Out 19 00:43:23 BRST 2009 Battery 1: discharging, 61%, 01:46:37 remaining Seg Out 19 00:44:23 BRST 2009 Battery 1: discharging, 60%, 01:43:37 remaining Seg Out 19 00:45:23 BRST 2009 Battery 1: discharging, 60%, 01:34:41 remaining Seg Out 19 00:46:23 BRST 2009 Battery 1: discharging, 59%, 01:42:59 remaining Seg Out 19 00:47:23 BRST 2009 Battery 1: discharging, 59%, 01:34:59 remaining Seg Out 19 00:48:23 BRST 2009 Battery 1: discharging, 58%, 01:34:05 remaining Seg Out 19 00:49:23 BRST 2009 Battery 1: discharging, 57%, 01:35:02 remaining Seg Out 19 00:50:23 BRST 2009 Battery 1: discharging, 57%, 01:38:28 remaining Seg Out 19 00:51:23 BRST 2009 Battery 1: discharging, 56%, 01:32:56 remaining Seg Out 19 00:52:23 BRST 2009 Battery 1: discharging, 55%, 01:38:18 remaining Seg Out 19 00:53:23 BRST 2009 Battery 1: discharging, 55%, 01:35:09 remaining Seg Out 19 00:54:23 BRST 2009 Battery 1: discharging, 54%, 01:29:34 remaining Seg Out 19 00:55:23 BRST 2009 Battery 1: discharging, 54%, 01:28:44 remaining Seg Out 19 00:56:23 BRST 2009 Battery 1: discharging, 53%, 01:25:33 remaining Seg Out 19 00:57:23 BRST 2009 Battery 1: discharging, 52%, 01:28:49 remaining Seg Out 19 00:58:23 BRST 2009 Battery 1: discharging, 52%, 01:28:03 remaining Seg Out 19 00:59:23 BRST 2009 Battery 1: discharging, 51%, 01:26:41 remaining Seg Out 19 01:00:23 BRST 2009 Battery 1: discharging, 50%, 01:27:20 remaining Seg Out 19 01:01:23 BRST 2009 Battery 1: discharging, 50%, 01:26:16 remaining Seg Out 19 01:02:23 BRST 2009 Battery 1: discharging, 49%, 01:25:15 remaining Seg Out 19 01:03:24 BRST 2009 Battery 1: discharging, 49%, 01:03:48 remaining Seg Out 19 01:04:24 BRST 2009 Battery 1: discharging, 48%, 01:22:12 remaining Seg Out 19 01:05:24 BRST 2009 Battery 1: discharging, 47%, 01:21:18 remaining Seg Out 19 01:06:24 BRST 2009 Battery 1: discharging, 47%, 01:17:24 remaining Seg Out 19 01:07:24 BRST 2009 Battery 1: discharging, 46%, 01:21:53 remaining Seg Out 19 01:08:24 BRST 2009 Battery 1: discharging, 45%, 01:18:38 remaining Seg Out 19 01:09:24 BRST 2009 Battery 1: discharging, 45%, 01:17:38 remaining Seg Out 19 01:10:24 BRST 2009 Battery 1: discharging, 44%, 01:17:43 remaining Seg Out 19 01:11:24 BRST 2009 Battery 1: discharging, 44%, 01:16:04 remaining Seg Out 19 01:12:24 BRST 2009 Battery 1: discharging, 43%, 01:16:23 remaining Seg Out 19 01:13:24 BRST 2009 Battery 1: discharging, 42%, 01:03:56 remaining Seg Out 19 01:14:24 BRST 2009 Battery 1: discharging, 42%, 01:03:20 remaining Seg Out 19 01:15:24 BRST 2009 Battery 1: discharging, 41%, 01:03:10 remaining Seg Out 19 01:16:24 BRST 2009 Battery 1: discharging, 41%, 01:09:42 remaining Seg Out 19 01:17:24 BRST 2009 Battery 1: discharging, 40%, 01:05:06 remaining Seg Out 19 01:18:24 BRST 2009 Battery 1: discharging, 39%, 01:05:20 remaining Seg Out 19 01:19:24 BRST 2009 Battery 1: discharging, 38%, 01:05:57 remaining Seg Out 19 01:20:24 BRST 2009 Battery 1: discharging, 38%, 01:03:46 remaining Seg Out 19 01:21:24 BRST 2009 Battery 1: discharging, 37%, 01:00:13 remaining Seg Out 19 01:22:24 BRST 2009 Battery 1: discharging, 37%, 01:01:40 remaining Seg Out 19 01:23:24 BRST 2009 Battery 1: discharging, 36%, 00:59:12 remaining Seg Out 19 01:24:24 BRST 2009 Battery 1: discharging, 35%, 01:00:31 remaining Seg Out 19 01:25:24 BRST 2009 Battery 1: discharging, 35%, 00:58:29 remaining Seg Out 19 01:26:24 BRST 2009 Battery 1: discharging, 34%, 00:57:23 remaining Seg Out 19 01:27:24 BRST 2009 Battery 1: discharging, 33%, 00:57:10 remaining Seg Out 19 01:28:24 BRST 2009 Battery 1: discharging, 33%, 00:55:25 remaining Seg Out 19 01:29:24 BRST 2009 Battery 1: discharging, 32%, 00:55:52 remaining Seg Out 19 01:30:24 BRST 2009 Battery 1: discharging, 32%, 00:54:45 remaining Seg Out 19 01:31:24 BRST 2009 Battery 1: discharging, 31%, 00:53:34 remaining Seg Out 19 01:32:24 BRST 2009 Battery 1: discharging, 30%, 00:53:14 remaining Seg Out 19 01:33:24 BRST 2009 Battery 1: discharging, 30%, 00:48:24 remaining Seg Out 19 01:34:24 BRST 2009 Battery 1: discharging, 29%, 00:47:46 remaining Seg Out 19 01:35:24 BRST 2009 Battery 1: discharging, 28%, 00:49:57 remaining Seg Out 19 01:36:24 BRST 2009 Battery 1: discharging, 28%, 00:47:10 remaining Seg Out 19 01:37:24 BRST 2009 Battery 1: discharging, 27%, 00:47:04 remaining Seg Out 19 01:38:24 BRST 2009 Battery 1: discharging, 26%, 00:44:00 remaining Seg Out 19 01:39:24 BRST 2009 Battery 1: discharging, 26%, 00:40:29 remaining Seg Out 19 01:40:25 BRST 2009 Battery 1: discharging, 25%, 00:39:58 remaining Seg Out 19 01:41:25 BRST 2009 Battery 1: discharging, 24%, 00:38:41 remaining Seg Out 19 01:42:25 BRST 2009 Battery 1: discharging, 24%, 00:40:41 remaining Seg Out 19 01:43:25 BRST 2009 Battery 1: discharging, 23%, 00:36:22 remaining Seg Out 19 01:44:25 BRST 2009 Battery 1: discharging, 22%, 00:38:15 remaining Seg Out 19 01:45:25 BRST 2009 Battery 1: discharging, 22%, 00:36:59 remaining Seg Out 19 01:46:25 BRST 2009 Battery 1: discharging, 21%, 00:34:42 remaining Seg Out 19 01:47:25 BRST 2009 Battery 1: discharging, 20%, 00:38:37 remaining Seg Out 19 01:48:25 BRST 2009 Battery 1: discharging, 20%, 00:36:23 remaining Seg Out 19 01:49:25 BRST 2009 Battery 1: discharging, 19%, 00:32:27 remaining Seg Out 19 01:50:25 BRST 2009 Battery 1: discharging, 19%, 00:33:38 remaining Seg Out 19 01:51:25 BRST 2009 Battery 1: discharging, 18%, 00:33:25 remaining Seg Out 19 01:52:25 BRST 2009 Battery 1: discharging, 17%, 00:32:01 remaining Seg Out 19 01:53:25 BRST 2009 Battery 1: discharging, 17%, 00:22:47 remaining Seg Out 19 01:54:25 BRST 2009 Battery 1: discharging, 16%, 00:29:30 remaining Seg Out 19 01:55:25 BRST 2009 Battery 1: discharging, 16%, 00:26:29 remaining Seg Out 19 01:56:25 BRST 2009 Battery 1: discharging, 15%, 00:28:22 remaining Seg Out 19 01:57:25 BRST 2009 Battery 1: discharging, 14%, 00:27:20 remaining Seg Out 19 01:58:25 BRST 2009 Battery 1: discharging, 14%, 00:25:20 remaining Seg Out 19 01:59:25 BRST 2009 Battery 1: discharging, 13%, 00:23:34 remaining Seg Out 19 02:00:25 BRST 2009 Battery 1: discharging, 13%, 00:23:26 remaining Seg Out 19 02:01:25 BRST 2009 Battery 1: discharging, 12%, 00:22:14 remaining Seg Out 19 02:02:25 BRST 2009 Battery 1: discharging, 11%, 00:19:04 remaining Seg Out 19 02:03:25 BRST 2009 Battery 1: discharging, 11%, 00:18:54 remaining Seg Out 19 02:04:25 BRST 2009 Battery 1: discharging, 10%, 00:18:21 remaining Seg Out 19 02:05:25 BRST 2009 Battery 1: discharging, 9%, 00:17:33 remaining Seg Out 19 02:06:25 BRST 2009 Battery 1: discharging, 9%, 00:16:34 remaining Seg Out 19 02:07:25 BRST 2009 Battery 1: discharging, 8%, 00:14:15 remaining Seg Out 19 02:08:25 BRST 2009 Battery 1: discharging, 8%, 00:14:06 remaining Seg Out 19 02:09:25 BRST 2009 Battery 1: discharging, 7%, 00:13:08 remaining Seg Out 19 02:10:25 BRST 2009 Battery 1: discharging, 7%, 00:11:48 remaining Seg Out 19 02:11:25 BRST 2009 Battery 1: discharging, 7%, 00:11:57 remaining Seg Out 19 02:12:25 BRST 2009 Battery 1: discharging, 6%, 00:11:07 remaining Seg Out 19 02:13:25 BRST 2009 Battery 1: discharging, 6%, 00:08:01 remaining Seg Out 19 02:14:25 BRST 2009 Battery 1: discharging, 5%, 00:09:45 remaining Seg Out 19 02:15:25 BRST 2009 Battery 1: discharging, 4%, 00:08:12 remaining Seg Out 19 02:16:25 BRST 2009 Battery 1: discharging, 4%, 00:06:40 remaining Seg Out 19 02:17:25 BRST 2009 Battery 1: discharging, 3%, 00:06:09 remaining Seg Out 19 02:18:26 BRST 2009 Battery 1: discharging, 3%, 00:04:58 remaining Seg Out 19 02:19:26 BRST 2009 Battery 1: discharging, 3%, 00:04:58 remaining Seg Out 19 02:20:26 BRST 2009 Battery 1: discharging, 3%, 00:04:57 remaining Seg Out 19 02:21:26 BRST 2009 Battery 1: discharging, 3%, 00:03:27 remaining Seg Out 19 02:22:26 BRST 2009 Battery 1: discharging, 3%, 00:03:36 remaining Seg Out 19 02:23:26 BRST 2009 Battery 1: discharging, 2%, 00:03:22 remaining Seg Out 19 02:24:26 BRST 2009 Battery 1: discharging, 2%, 00:02:21 remaining Seg Out 19 02:25:26 BRST 2009 Battery 1: discharging, 1%, 00:01:24 remaining # time of death shows 02:25, wich means 26 min more than initially predicted... Now I know my battery lasts 2 hours and 25 minutes...
Needs to be run in a battery sysfs dir, eg. /sys/class/power_supply/BAT0 on my system. Displays the battery's current charge and the rate per-second at which energy is {dis,}charging. All values are displayed as percentages of "full" charge. The first column is the current charge. The second is the rate of change averaged over the entire lifetime of the command (or since the AC cable was {un,}plugged), and the third column is the rate of change averaged over the last minute (controlled by the C=60 variable passed to awk). The sample output captures a scenario where I ran 'yes' in another terminal to max out a CPU. My battery was at 76% charge and you can see the energy drain starts to rise above 0.01% per-second as the cpu starts working and the fan kicks in etc. While idle it was more like 0.005% per-second. I tried to use this to estimate the remaining battery life/time until fully charged, but found it to be pretty useless... As my battery gets more charged it starts to charge slower, which meant the estimate was always wrong. Not sure if that's common for batteries or not. Show Sample Output
Fully recharge your computer battery and start this script. It will create or clean the file named battery.txt, print a start on it and every minute it will append a time stamp to it. Batteries last few hours, and each hour will have 60 lines of time stamping. Really good for assuring the system was tested in real life with no surprises. The last time stamp inside the battery.txt file is of interest. It is the time the computer went off, as the battery was dead! Turn on your computer after that, on AC power of course, and open battery.txt. Read the first and last time stamps and now you really know if you can trust your computer sensors. If you want a simple line of text inside the battery.txt file, use this: watch -n 60 'date > battery.txt' The time of death will be printed inside Show Sample Output
Remaining battery time is displayed in minutes Show Sample Output
Convenient to leave running in a yakuake or plasmacon terminal.
For older kernels
watch -n 5 cat /proc/acpi/battery/BAT0/state
Show Sample Output
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Send an http HEAD request w/curl
mniskin
11
List only executables installed by a debian package
depesz
4
Replicate a directory structure dropping the files
rocketraman
1
watch your network load on specific network interface
qiaomuf
2
Repeat a portrait eight times so it can be cut out from a 6"x4" photo and used for visa or passport photos
hackerb9
3
find broken symbolic links
jianingy
8
ssh tunnel with auto reconnect ability
jianingy
13
Get all IPs via ifconfig
snahor
1
prints the parameter you used on the previous command
frankman
3
Dump the root directory to an external hard drive
luqmanux
2
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: