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.

1
  • 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, 2020 at 7:49

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .