4 ms·
If you want to execute commands on multiple remote hosts over SSH, just run a tmux session and launch a tab on each host in a loop and execute them. It's far e
by mekster 5y ago
If you want to execute commands on multiple remote hosts over SSH, just run a tmux session and launch a tab on each host in a loop and execute them.
It's far easier to follow the output and individually deal with prompts.
- permalac 5y agoI do the same, I even have a command that tells me which tmux panel I'm in so I can ssh to many servers at once from tmux. However, when you just want to execute the same command : https://clustershell.readthedocs.io/en/latest/tools/clush.html https://clustershell.readthedocs.io/en/latest/tools/clush.ht...
- paskozdilar 5y agoTrue, but for a large number of hosts, going manually through prompts doesn't scale anymore. Sometimes you just want to check whether all hosts have the same configuration file, or something like that. That's where GNU Parallel can save your gluteus maximus: cat hosts.txt | parallel --quote --timeout=10 ssh {} 'echo {} $(md5sum ~/.config/file)' The above command would take a list of hostnames from the hosts.txt file, connect to each one, hash the config file and print out hostnames and hashes in one line per host.
- mekster 5y agoUnless entire operations can be finished automatically, you could still do, command_to_test && exit in the swarm of tmux tabs and let only the anomalies stay open.
- MainJane 5y agocat hosts.txt | parallel --quote --timeout=10 ssh {} 'echo {} $(md5sum ~/.config/file)' Also try: parallel --slf hosts.txt --timeout=10 --nonall --tag md5sum .config/file
- ktm5j 5y agoI love tmux for this application, and typically I tend to prefer alternate solutions to using parallel.. but to be fair there are many more usecases for parallel than the one you describe here.
- MainJane 5y agoAlso try: parallel --tmux ...