錯誤描述:
不知道因為什么原因,tmux掛掉了。 顯示“failed to connect to server”消息
嘗試使用tmux ls 獲取當前正在運行的會話列表時。報錯
failed to connect to server: Connection refused
使用tmux時,無法重新連接。
$ tmux attach
no sessions
但是查看tmux 服務的時候,還是存在的。
$ ps -aef | fgrep -i tmux
hari 7139 1 1 2016 ? 2-20:32:31 tmux
hari 25943 25113 0 22:00 pts/0 00:00:00 fgrep --color=auto -i tmux
解決方案
這說明tmux服務器仍在運行,但是仍然顯示tmux ls failed to connect to server: Connection refused錯誤。 驗證了下屬於tmux會話的tmp目錄,並且lsof -p 7139 (tmux服務器的pid)顯示套接字文件已打開:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
tmux 7139 hari 5u unix 0x0000000000000000 0t0 1712879255 /tmp/tmux-50440/default
也嘗試明確指定-S /tmp/tmux-50440/default為tmux,但沒有反應。
搜了一下, StackOverflow上的解決方案是 “Try sending SIGUSR1 signal to the tmux server process.”
嘗試將SIGUSR1信號發送到tmux服務器進程。
因為在tmux的文檔中也提到,發送SIGUSR1將使tmux重新創建套接字文件。嘗試了這種方法后,就能找到會話並重新連接了。
$ kill -s USR1 7139
$ tmux ls
0: 12 windows (created Mon Apr 18 21:17:55 2016) [198x62]