timestamp in .sh_history using ksh shell

Hello Everyone:

Does anyone know how I will setup my account to put timestamp in my .sh_history? I do not hold the root account. I am using AIX 5 and ksh shell. I tried every solution I can find in the internet but nothing seems to work OR I am just applying those in the wrong way. Anyone knows a "sure" way? I would appreciate your help. Thanks.

~Orbix

ksh does not have support for adding timestamps to the command history file.

A common hack is to modify PS1 to add a timestamp line into the command history file each time the PS1 prompt is output.

PS1='$(printf "%(%D %T )T" | read -s)$ '

Note that the Bash command history timestamp shows the time each command is started. This hack shows the time each command finishes.

I put the "PS1=..." command in my .profile but it didn't work when I look at the .sh_history

PS1=....
export

I put the "PS1=..." command in my .profile but it didn't work when I look at the .sh_history

PS1='$(printf "%(%D %T )T" | read -s)$ '
export PS1

AIX supports timestamps in the ksh and ksh93 shell history from AIX 5.3 on. Export EXTENDED_HISTORY=ON from the /etc/profile or your ~/.profile (no need to be root) and check with fc -t.