3

I added date and time to my linux history with this command:

export HISTTIMEFORMAT='%F %T '

When I actually go to view my history anything that I didn't actually do today seems to pick a time that I last queried those commands rather than when I actually used them.

  744  2013-05-22 10:04:20 java -jar ... 
  745  2013-05-22 10:04:20 java -jar ...
  747  2013-05-22 10:04:20 java -jar ...
  748  2013-05-22 10:04:20 java -jar ...
  749  2013-05-22 10:04:20 java -jar ...
  750  2013-05-22 10:04:20 java -jar ...
  781  2013-05-22 10:04:20 java -jar ...
  996  2013-05-22 09:51:22 history | grep ...
  999  2013-05-22 09:58:18 history | grep ...
 1001  2013-05-22 10:05:22 history | grep ...
 1003  2013-05-22 10:05:39 history | grep ...

While I find it amusing, that it seems like I travelled through time, I was hoping someone could give a reason for this behaviour. Is there a better command to use? Is my bash just acting silly?

Is there some information that I am leaving out that could be of use? Versioning, etc?

I see there was a vote to close this question. If there is a more appropriate place for this question, I won't mind it being moved.

1
  • The vote was probably to move it to superuser, as this isn't code, but config.
    – demure
    May 22, 2013 at 14:39

1 Answer 1

1

If you've only just set HISTTIMEFORMAT, this is to be expected. From the bash manpage:

If this variable is set, time stamps are written to the history file so they may be preserved across shell sessions.

Commands executed in your current shell have correct timestamps because the shell remembers. However, if HISTTIMEFORMAT wasn't set in previous sessions, the timestamps weren't recorded at all. You can see this by looking in ~/.bash_history: if you don't see lines that look like #1369236382, the file contains no timestamps.

You must log in to answer this question.

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