where does history timestamp stored before i enable it

7,672

Bash always remembers timestamps, the HISTTIMEFORMAT variable merely determines what gets written to ~/.bash_history. So for commands bash reads from its history file, it only knows the timestamps if they have been written to it, but it always knows its "own" timestamps.

Share:
7,672

Related videos on Youtube

林果皞
Author by

林果皞

Updated on September 18, 2022

Comments

  • 林果皞
    林果皞 over 1 year

    I tried to set timestamp for history. My first attempt was do export EXTENDED_HISTORY=ON command, and it seems like doesn't work. Then i do echo 'export HISTTIMEFORMAT="%d.%m.%y %T "' >> /etc/bash.bashrc command, and it works.

    After i enabled the timestamp, i do . /etc/bash.bashrc to reload it, then i do history to show my history with timestamp.

    But the weird thing i noticed was how does the history can store the timestamp before i enable it?

    The first part of my history, all commands have the same timestamp 20:43:04: enter image description here

    The second part, start from 619th command, the commands have save their own timestamp, but at this moment, i never enable the history timestamp yet.

    enter image description here

    Instead, i enable the history timestamp at 694th command:

    enter image description here

    My $HISTSIZE is set long time ago which was 1000 lines. I using Konsole 2.10.5 terminal and Ubuntu 13.04.

    I have no idea the cache is a feature from Konsole or bash.

    My question is, how and where does history store the timestamp before i do 'export HISTTIMEFORMAT="%d.%m.%y %T "' >> /etc/bash.bashrc`?

    And it seems like have limitation because not all previous history timestamp is store(i.e. 1st to 618th command share the same timestamp). May be it's because of 619th command is the first command for this konsole tab session, i don't remember.

  • rusty shackleford
    rusty shackleford over 4 years
    This isn't correct, bash will record a timestamp in .bash_history only when HISTTIMEFORMAT is set.