Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Enable Time stamps in bash history  (Read 1652 times)

0 Members and 1 Guest are viewing this topic.

aneeshs

  • Guest
Enable Time stamps in bash history
« on: August 05, 2017, 04:49:10 pm »
To display shell command history with date and time under a Linux,


1.Defining the environment variable named HISTTIMEFORMAT as follows:
Code: [Select]
$ HISTTIMEFORMAT="%d/%m/%y %T "

Where,
%d – Day, %m – Month, %y – Year, %T – Time

2. Use the source command to load HISTTIMEFORMAT from the file into the current shell script or a command prompt:
Code: [Select]
$ . ~/.bash_profile_file

Sample Output:
Code: [Select]
$ history
Code: [Select]
  519  05/08/17 16:43:41 history
  520  05/08/17 16:43:53 w
  521  05/08/17 16:43:56 iostat
  522  05/08/17 16:44:01 top
  523  05/08/17 16:44:07 at
  524  05/08/17 16:44:09 q
  525  05/08/17 16:44:20 history

:)