Neo2SHYAlien

dmesg -T

Aug 30th, 2016
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. # Translate dmesg timestamps to human readable format
  3.  
  4. # uptime in seconds
  5. uptime=$(cut -d " " -f 1 /proc/uptime)
  6.  
  7. # remove fraction
  8. uptime=$(echo $uptime | cut -d "." -f1)
  9.  
  10. # run only if timestamps are enabled
  11. if [ "Y" = "$(cat /sys/module/printk/parameters/time)" ]; then
  12.   dmesg | sed "s/[^\[]*\[/\[/" | sed "s/^\[[ ]*\?\([0-9.]*\)\] \(.*\)/\\1 \\2/" | while read timestamp message; do
  13.     timestamp=$(echo $timestamp | cut -d "." -f1)
  14.     ts1=$(( $(busybox date +%s) - $uptime + $timestamp ))
  15.     ts2=$(busybox date -d "@${ts1}")
  16.     printf "[%s] %s\n" "$ts2" "$message"
  17.   done
  18. else
  19.   echo "Timestamps are disabled (/sys/module/printk/parameters/time)"
  20. fi
RAW Paste Data