Tip #534 Adding times to the history
Typically when one types the history command, it displays the command number and the command. For auditing purposes it would be helpful to display the timestamp as well. To do so we need to set the environmental variable HISTTIMEFORMAT.HISTTIMEFORMAT supports format strings of strftime.
Some important format strings:
%T Replaced by the time ( %H : %M : %S )
%F Equivalent to %Y - %m - %d
$ export HISTTIMEFORMAT='%F %T '
Now execute
$ history
it will print the command line history with corresponding timestamp when the command was executed, such as:
499 2009-02-11 18:20:52 ls
- TAGS:
- history
alias aptitude at awk bash bc cal cat cd colrm comm cp csh curl cut date dd df dialog diff dirname dpkg du fc find fuser grep gs gzip history iconv kill ksh last less ln ls lsof lynx m4 md5sum mkdir mkfifo mkisofs mv mysql nc netstat openssl OSX perl ping popd ps pushd python read redirection rm scp screen sed sort ssh stat sudo svn tail tar tee test top tr uniq vim wc wget xargs