The command using ‘;’ after ‘&’ like
ssh host1 hostname &; ssh host2 hostname &
Leads to error like
bash: syntax error near unexpected token `;'
Why does ; after & lead to unexpected token error in bash on Linux? And what’s the solution?
The quick fix is to change your command to
ssh host1 hostname & ssh host2 hostname &
“;” and “&” are command terminators (newline(s) imply “;” unless there is a “” to continue the line) and Bash does not allow empty commands.
&; means start the previous command in background (
&) and the start a
; command in foreground. The later one is empty and is not allowed by Bash.