0

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.

1

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.

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.