0

I usually open a local tmux session that connects to multiple remote tmux sessions over ssh. These lab machines run continuous regressions. When the laptop goes to sleep overnight the pipes are broken with the ssh sessions (expected). The next morning I had to restart each one of the windows manually. Is there a way for tmux to automatically figures that the machine is back online and tries to reconnect to the ssh sessions in each of these windows?

Somewhat like a vnc viewer that reconnects automatically when the machine is back online.

  • Consider having 1 remote session which connects to all the other remote sessions, so you only need to reconnect to 1? Use the scripting builtin to tmux to just run a script to reconnect? – icarus Mar 27 at 7:49
1

You could just run something like this in each window:

while :; do ssh $i tmux a; sleep 1; done

Or write a script that checks the windows periodically and uses respawn-pane or respawn-window to restart them if necessary.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.