Skip to content

Instantly share code, notes, and snippets.

@jhannah
Last active June 6, 2019 17:10
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 jhannah/3b50587d643222c00e3c83b4738b08ff to your computer and use it in GitHub Desktop.
Save jhannah/3b50587d643222c00e3c83b4738b08ff to your computer and use it in GitHub Desktop.
tmux to multiple servers (one in each window), run commands (public version)
So say you have a cluster of boxes called "qa10". You can just run "qa10.sh" and
through the magic of tmux you're connected to ALL of them and looking at whatever
it is you're interested in.
$ cat qa10.sh
tmux new-session "tmux source-file qa10.tmux.conf"
$ cat qa10.tmux.conf
rename-session qa10
new-window -n qa10-1
send-keys -t qa10-1 'ssh qa10-n1.yourdomain.com' C-m
send-keys -t qa10-1 'tail -f /apps/my.log ' C-m
new-window -n qa10-2
send-keys -t qa10-2 'ssh qa10-n2.yourdomain.com' C-m
send-keys -t qa10-2 'tail -f /apps/my.log ' C-m
new-window -n qa10-3
send-keys -t qa10-3 'ssh qa10-n3.yourdomain.com' C-m
send-keys -t qa10-3 'tail -f /apps/my.log ' C-m
new-window -n qa10-4
send-keys -t qa10-4 'ssh qa10db-n1.yourdomain.com' C-m
send-keys -t qa10-4 'psql my_db developer' C-m
send-keys -t qa10-4 'select report_name, status from report_queue_entries\;' C-m
My tmux cheat sheet:
https://gist.github.com/jhannah/0e4a3d691c1f0169d57d667c3e78be26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment