I want to know how long the system will last on a full battery.Why do you care so much about uptime? The datetime stamps in /var/log/messages will tell you when the system started shutting down, assuming it does a 'proper' shutdown, not an instant off kind of thing.
Does dmesg record the time of a shutdown when a system shuts down when it runs out of power?It's easy enough to figure out when the system booted (that's in the log), and when it shut down. Either the shutdown is in the log, or regular log updates from other subsystems stop happening. Then calculate the difference yourself.
Not quite what you're after but does report number of startups/shut downs, system life etcsysutils/tuptime
> tuptime
System startups: 111 since 15:22:20 28/06/2025
System shutdowns: 98 ok + 12 bad
System life: 354d 4h 11m 44s
Longest uptime: 14d 12h 7m 38s from 22:34:36 16/09/2025
Average uptime: 1d 22h 24m 54s
System uptime: 60.61% = 214d 16h 4m 34s
Longest downtime: 42d 5h 21m 34s from 12:13:32 14/02/2026
Average downtime: 1d 6h 26m 15s
System downtime: 39.39% = 139d 12h 7m 10s
Current uptime: 9h 40m 42s since 09:53:22 17/06/2026
Never heard of tuptime before but thanks for drawing my attention to it.Not quite what you're after but does report number of startups/shut downs, system life etc