history command does not show commands in time order

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • bash-3.2-32.el5

Issue

  • history command does not show commands in time order when HISTTIMEFORMAT is defined in /etc/profile .

Resolution

  • To get around this problem, have the below entry in /etc/bashrc file
PROMPT_COMMAND='history -a; history -r; echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

Diagnostic Steps

  • Add the following to reproduce the issue in /etc/profile.
HISTTIMEFORMAT="${CYAN}[ %d/%m/%Y %H:%M:%S ]${NORMAL}  "
HISTFILESIZE=100000
HISTSIZE=10000
export HISTTIMEFORMAT HISTFILESIZE HISTSIZE

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments