0

How can I make sure that my bash history gets written to ~/.bash_history when I am disconnected abnormally?

I work on several remote Linux hosts, and my connection is frequently terminated abnormally. When that happens, my recent bash history is not available when I reconnect. I suspect that the abnormal termination is preventing the bash shell from writing to ~/.bash_history. I can't control the disconnects, and other than losing my history, the abnormal disconnects don't cause a problem.

I don't want to interfere with the normal history mechanism. In other words, I don't want a hack that messes up the history process. Thanks!

EDIT:

I am concerned about the ~/.bash_history on the remote machine.

The immediate write method may be the best way to go. The abnormal termination event may not allow a final dump to ~/.bash_history.

I have keep alive set up for ssh, but the remote hosts don't always allow that.

wdb
  • 115

0 Answers0