Linux - How to enable dmesg time stamps at boot time, Trick to enable dmesg time stamps at boot time

How to enable dmesg time stamps at boot time

How to Enable dmesg time stamps at boot time

In Linux OS user startup scripts can be added in /etc/rc.d/rc.local. As a best practice, it is recommended to create a separate start-up script /etc/rc.d/rc.local.user to separate Linux OS initialization commands from user-defined commands.

Check whether the /etc/rc.d/rc.local start-up script contains the call for /etc/rc.d/rc.local.user script

 # grep -C 1 \'rc.local.user\' /etc/rc.d/rc.local
You must get below output
  if [ -f /etc/rc.d/rc.local.user ]; then
    /etc/rc.d/rc.local.user
  fi

Create the start-up script for user-defined commands
 # touch /etc/rc.d/rc.local.user

Add these lines into the /etc/rc.d/rc.local.user script:
 #!/bin/bash
 # enable time stamps in dmesg
   echo Y > /sys/module/printk/parameters/time 

Assign proper permission to the file
 # chmod -v u=rwx,g=rx,o=rx /etc/rc.d/rc.local.user 

Reboot the machine and check whether the logs are written with time stamps or not.
 # dmesg | tail -n 5 

   .............
   [16952.759416] Love U Dear
   [17640.647726] lp: driver loaded but no devices found

The topic on Linux - How to enable dmesg time stamps at boot time is posted by - Vaishna

Hope you have enjoyed, Linux - How to enable dmesg time stamps at boot timeThanks for your time

Tech Bluff