Display Date And Time For Each Bash Command

Categories General Info

To display shell command history with date and time under a UNIX or Linux operating systems, set up the HISTTIMEFORMAT. This will set the timestamp information associated with each bash entry in history that is written to the history file.

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile

To see history type
history
Sample output:
683 20140903 - 07:50:57 - history |grep yum
684 20140904 - 09:42:36 - yum update
685 20140904 - 09:44:16 - uname -a
686 20140904 - 09:44:30 - reboot -e
687 20140904 - 09:45:09 - shutdown -r now
688 20140904 - 09:45:12 - exit

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.