Skip to content

Instantly share code, notes, and snippets.

@chrischoy
Created January 2, 2018 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrischoy/a21bbf7ee0b3eb74080958f02aa488f8 to your computer and use it in GitHub Desktop.
Save chrischoy/a21bbf7ee0b3eb74080958f02aa488f8 to your computer and use it in GitHub Desktop.
Connect to all servers and restore tmux session
#!/bin/bash
tmux start-server
tmux new-session -d -s napoli -n monitor
SERVERS=(napoli101 napoli102 napoli103 napoli104 napoli105 napoli106 napoli107 napoli108 napoli109 napoli110 napoli111 napoli112 visionlab-dgx1)
# ${#array[@]} is the number of elements in the array
for ((i = 0; i < ${#SERVERS[@]}; ++i)); do
tabnum=$(( $i + 1 ))
tmux new-window -t napoli:$tabnum
tmux send-keys -t napoli:$tabnum "ssh ${SERVERS[$i]}" C-m
tmux send-keys -t napoli:$tabnum "tmux -2 a" C-m
done
tmux select-window -t napoli:monitor
tmux -2 attach-session -t napoli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment