天天看點

不同session的history操作同步問題

不同session的history操作同步問題

openssh不同時間開的不同session,相同使用者的history指令顯示的是不完全相同的…不過bash的設計是有它的考慮的...要不chsh到zsh用用...

不同session的history操作同步問題

可能影響session的history選項就如下幾個:

不同session的history操作同步問題

源碼看,暫時沒有查出什麼時候會統一寫入 .bash_history檔案!小坑要小心呀

不同session的history操作同步問題
不同session的history操作同步問題

幾個簡單的實驗,不同session的bash history是不同步的!

<a target="_blank" href="https://ask.fedoraproject.org/question/9954/how-to-keep-history-commands-in-sync-across-multiple-sessions/">參考位址</a>

不同session的history操作同步問題

<a target="_blank" href="http://nodsw.com/blog/leeland/2011/10/26-all-bash-history-forever-and-across-multiple-sessions">參考位址</a>

四個腳本備忘://注意将.bashrc.user&amp;bash_history_all_append.sh在.bashrc或其他登入shell中添加執行.

1. ${home}/.bashrc.user

2.  ${home}/.bash.parse_history.awk

3. ${home}/.bash_history.sed

4. ${home}/.bash_history_all_append.sh 

5. cat ~./bash_history_all即可.

可以看到不同終端的不同指令,當然還有指令執行的時間~nice.

^.^

不同session的history操作同步問題

……