How to have separate command history for different sessions for the same user?
You can add HISTFILE=~/.hist$$
to your .profile
.
This should generate a unique file per session.
You will end up with a large number of .hist*
so I suggest you remove them occasionally.
From the ksh faq:
Q1. How do I get separate history files for shell?
A1. ksh uses a shared history file for all shells that use the same history file name. This means that commands entered in one window will be seen by shells in other windows. To get separate windows, the HISTFILE variable needs to be set to different name before the first history command is created.
I'm assuming you are talking about simultaneous sessions; separating sessions that are after one another isn't very useful: you would never be able to use it's history anymore, because all sessions would be unique. If that were the case, you would probably be better off just disabling command history.
If we are talking about separating simultaneous session, I'd recommend you use Bash. I'm pretty sure I'm not getting the command history from two simultaneous sessions mixed with it. Bash only writes history to .bash_history
at logout, so command history won't get mixed until after logout. Provided that using Bash is acceptable, would that solve your issue?