Hello Guys,

If you are using a bash shell then using following command you can set the time in history so that you will get a better idea at what time the command was fired.
HISTTIMEFORMAT=”%D %T ”

If you have ksh doesn’t have any feature intended to put timestamps in history. You can get a similar effect by combining the evaluation of the PS1 prompt and the “read -s” feature that reads into history.

PS1=’$(printf “%(# %D %T )T” | read -s)$ ‘

This prompt setting will put the current date and time into the history each time ksh comes back to printing a prompt. The timestamp will appear as a separate line. It will show the time that the preceeding command completed. You won’t be able to know exactly when a long-running command was started. (The bash timestamp feature shows the start times of entered commands and doesn’t show when they finish.)

You can also try following step.

HST=`hostname`
USR=`who -um | awk ‘{print $1}’`
NAME=`whoami`# Set History File
HISTFILE=/home/root/.sh_history_”${HST}”_”${USR}”-as-”${NAME}”_`date +%y%m%d.%
H%M%S_$$`
export HISTFILE

Thats it.

Enjoy..