HISTTIMEFORMAT='%F %T' I tried to query
But the result shows all the commands are executed on same day.
How can I check the actual date and time of actual command execution?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
If you set the
HISTTIMEFORMAT in bash your new entries get stored in the history file with a timestamp, older commands that don't have a timestamp (those before you ever set
HISTTIMEFORMAT will display one and the same date-time-stamp (I assume the one from the first entry found with a real timestamp).
This problem should solve itself after your complete history has been updated in a few days.
You can look in
~/.bash_history to see what is the first line that has a date-time-stamp. Those are lines starting with a
# followed by a (currently) 10 digit number.
I think this is a feature. As you just changed this setting, you can see from
~/.bash_history that the old command do not have a time-stamp stored. So for these commands, it will just assume the current time.
Try to put the
export command in
~/.bashrc and execute a few command. You will see, that in
~/.bash_history an additional time-stamp will be save, which can then be displayed by
history. So for new commands it should work as expected.
Thus: Not backwards compatible with commands executed in a different terminal window in the past.