Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Translate dmesg timestamps to human readable format
- # uptime in seconds
- uptime=$(cut -d " " -f 1 /proc/uptime)
- # remove fraction
- uptime=$(echo $uptime | cut -d "." -f1)
- # run only if timestamps are enabled
- if [ "Y" = "$(cat /sys/module/printk/parameters/time)" ]; then
- dmesg | sed "s/[^\[]*\[/\[/" | sed "s/^\[[ ]*\?\([0-9.]*\)\] \(.*\)/\\1 \\2/" | while read timestamp message; do
- timestamp=$(echo $timestamp | cut -d "." -f1)
- ts1=$(( $(busybox date +%s) - $uptime + $timestamp ))
- ts2=$(busybox date -d "@${ts1}")
- printf "[%s] %s\n" "$ts2" "$message"
- done
- else
- echo "Timestamps are disabled (/sys/module/printk/parameters/time)"
- fi
Add Comment
Please, Sign In to add comment