Created
January 2, 2018 23:50
-
-
Save chrischoy/a21bbf7ee0b3eb74080958f02aa488f8 to your computer and use it in GitHub Desktop.
Connect to all servers and restore tmux session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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