Timestamps in bash
February 16, 2010
This is common knowledge but I found it so useful that I have to make sure it spreads even more :)
You can make bash register timestamps in its history:
export HISTTIMEFORMAT='[%F %T] '
And you can even alter the bash prompt to show timestamps as well, using the variable PROMPT_COMMAND:
export PROMPT_COMMAND="echo -n \[\$(date +%H:%M:%S)\]\ "
Voila! No more problem trying to figure out when things happened and how long time they took.
Of course, those 2 lines should be added to your ~/.bash_profile or equivalent for persistence.
You can make bash register timestamps in its history:
export HISTTIMEFORMAT='[%F %T] '
And you can even alter the bash prompt to show timestamps as well, using the variable PROMPT_COMMAND:
export PROMPT_COMMAND="echo -n \[\$(date +%H:%M:%S)\]\ "
Voila! No more problem trying to figure out when things happened and how long time they took.
Of course, those 2 lines should be added to your ~/.bash_profile or equivalent for persistence.