Linux/Basic commands/parallel/Execute a command in parallel by ssh


 * 1) /Execute a command in parallel by ssh/ in MACHINE1 and MACHINE2 using parallel


 * . See also pssh.
 * -q quote command. The command must be a simple command (see man bash) without redirections and without variable assignments. This will quote the command line and arguments so special characters are not interpreted by the shell.
 * -q quote command. The command must be a simple command (see man bash) without redirections and without variable assignments. This will quote the command line and arguments so special characters are not interpreted by the shell.

Using variables:

or creating a basic shell script: MACHINES="$1" COMMAND="$2"
 * 1) !/bin/bash

if [ $# -eq 0 ]; then echo -e '\nUSAGE: $0 "machine1 machine2 machine3" "command"\n' exit 0 fi

parallel --keep-order -q ssh {} "echo {}; $COMMAND" ::: $MACHINES

You can have a similar solution with a  loop but in this case command output will be mixed between both commands.