The Busybox dmesg command lacks the -T option to convert and display timestamps, so I tried converting them with a one-liner.
One-liner
uptime=$(cut -d. -f1 /proc/uptime); dmesg | while read line; do time=$(echo $line | sed -e 's/^\[ *\([0-9]*\).*$/\1/g'); echo "[$(date -d @$(($(date +%s) - $uptime + $time)))] $(echo $line | cut -d ] -f 2 -)" ; done
Brief Explanation
- /proc/uptime records the elapsed time since the system was started in seconds.
- The timestamps output by dmesg are the elapsed time since the system was started.
- By subtracting the elapsed time since the system was started from the current time, you can determine the system’s start time.
Current time - (Total uptime - dmesg timestamp) = Log time