Add timestamp to terminal in Linux
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:[email protected]:~#
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] [email protected]:~$
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.
本文系统（linux）相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统