In a ssh session every time that I open it I assign a value to a variable. Then I remove history with command rm -f .sh_history. Everything is ok but why if I have other session opened and I do an history it shows me that commands?
After removing the history file, why do I still have older commands in the history?
ksh;command history
I can't say exactly for ksh, but from the experience with other shells - they cache current session history and push it to the file on exit.  So history file removal affects on a new session, not the currently opened.