where does history timestamp stored before i enable it
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.
Related videos on Youtube
林果皞
Updated on September 18, 2022Comments
-
林果皞 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 doecho '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 dohistory
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:
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.
Instead, i enable the history timestamp at 694th command:
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 over 4 yearsThis isn't correct,
bash
will record a timestamp in.bash_history
only whenHISTTIMEFORMAT
is set.