Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



I 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.ht...


True, 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.


    cat hosts.txt | parallel --quote --timeout=10 ssh {} 'echo {} $(md5sum ~/.config/file)'
Also try:

    parallel --slf hosts.txt --timeout=10 --nonall --tag md5sum .config/file


Unless 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.


I 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.


Also try:

    parallel --tmux ...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: