8

When history command is executed, it shows a list of recently executed commands. Is there any provision with which we can see the time at which those particular commands were executed?

14

You need to set the HISTTIMEFORMAT env variable.

From help history:

If the $HISTTIMEFORMAT variable is set and not null, its value is used
as a format string for strftime(3) to print the time stamp associated
with each displayed history entry.  No time stamps are printed otherwise.

The format is described in the strftime manpage.

See examples here and here. The most useful one is probably

$ export HISTTIMEFORMAT='%F %T '
$ history|tail -2
501  2014-11-03 20:51:41 export HISTTIMEFORMAT='%F %T '
502  2014-11-03 20:51:44 history
  • 2
    Try to add a bit more information from the link. – DisplayName Nov 3 '14 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.