Shell – Run command in multiple active shells simultaneously

shelltmux

I am using tmux environment and often times I have to run the same python script in 4 different panes (top 4 in the image) with same command line arguments. Is there a way I can execute the script on each shell by executing command on one?

I am aware of this discussion but they suggest using a different terminal environment, I am looking for something that can be done using tmux
or shell scripting.

Tmux session

The four different shells are ssh sessions to 4 different VMs.

Best Answer

No need for any tools. tmux can handle this:

just open up the panes, ssh to the individual servers, and then Ctrl-B followed by

:setw synchronize-panes 

and all input gets synchronized to all visible panes.
Re-type this or add "off" to the command to leave.

Related Question