Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

Add timestamp to terminal in Linux

$
0
0

I came across an issue few weeks back at work when I did some troubleshooting and ran some commands. When I was documenting it, I just couldn’t remember the exact time I started troubleshooting and issued those commands; I mean I even had putty logs saved for 9 hours of troubleshooting data. At that point I really felt the need to add timestamp to terminal so that I would know what I did and when.

This is our usual linux terminal or bash shell prompt:

root@kali:~#

Added this line in .bashrc file.

export PROMPT_COMMAND="echo -n \[\$(date +%F-%T)\]\ "

and my Terminal prompt now looks like this:

[2016-10-08-00:47:25] root@kali:~$
Add timestamp to terminal in Linux
So next time, I save the output of my putty or of my terminal session, I would know exactly what I did and when I did.

Pretty neat way and saves a lot of headaches if you ask me. It’s not something new and if you’re like Jeff, then you would know it already… but I am not Jeff and not many people are, so just added this to my list of collection. Enjoy.


Viewing all articles
Browse latest Browse all 11063

Trending Articles