Enabling history to display time via export HISTTIMEFORMAT='%F %T ' shows the times of the commands but .bash_history doesn't contain any times.

Where does bash store the times the commands were executed?

Are they always stored automatically?

  • I just checked via history | less and all the commands from some hours back use the same time, so it is probably storing the times only for the current session
    – vfclists
    Commented Jan 3, 2014 at 14:41
  • possible duplicate of Finding command execution time in hindsight
    – slm
    Commented Jan 3, 2014 at 15:29
  • 1
    @slm not a dupe, this one is asking where the information is stored, not how to get it.
    – terdon
    Commented Jan 3, 2014 at 22:46
  • @terdon - retracted, but still feels like a dup to me. The only new thing here is the history -a bit.
    – slm
    Commented Jan 3, 2014 at 22:55

1 Answer 1


From the BASH_BUILTINS man page:

If the HISTTIMEFORMAT variable is set, the time stamp information associated with each history entry is written to the history file, marked with the history comment character. When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the previous history line.

So the information is stored in the history file only if HISTTIMEFORMAT is set.

(Try history -a to append the currently in-memory history entries to your history file. You should now see comments with unix timestamps in there.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .