0

I am running below bash script which is saving the history in a file, however it is logging the history with Unix epoch timestamp. I need the timestamp in human readable format.


_who_am_i=$(who am i|awk '{print $1}')
_ID=$(id -u $_who_am_i)
if [ "$_ID" > 0 ]
then
export HISTSIZE=10000
export HISTTIMEFORMAT="%F %T "
export HISTFILE=/var/log/users_historylogs/history-users-$(who am i | awk '{print $1}';exit)-$(date +%F)
export PROMPT_COMMAND='history -a'
fi

1 Answers1

0

As documented in the Fine Manual, the HISTTIMEFORMAT variable applies to the output of the history command. The history file always contains Unix timestamps. This is necessary so that the bash itself can parse it.

Tilman Schmidt
  • 4,101
  • 12
  • 27