Score:0

Geting UNIX Timestamp while logging history

ar flag

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
Score:0
bd flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.