Monday, November 19, 2012

Enable history timestamp for bash history command

Here is a way of how you can see a timestamp for executed command when using "history" command in Linux.



You can export HISTTIMEFORMAT variable, with appropriate date formatting.

For example you can use:

export HISTTIMEFORMAT='%F %H:%M:%S '

In this case the history command will give you an output like this:
~> history

   95  2012-11-19 09:46:04 cat xopus.html.1
   96  2012-11-19 09:46:04 su -
   97  2012-11-19 09:46:04 exit
   98  2012-11-19 09:46:04 ping wwwndfe1
   99  2012-11-19 09:46:04 mkdir ~/.ssh/
  100  2012-11-19 09:46:04 su -
  101  2012-11-19 09:46:08 set | grep HISTTIMEFORMAT
  102  2012-11-19 09:46:44 history

No comments:

Post a Comment