Sample Header Ad - 728x90

Parallel execution of remote commands

1 vote
4 answers
1325 views
### The setup: ### I have a PHP script (currently written for PHP5.5, but the server it runs from has 7.4) that processes files that contain lists of linux servers, then runs a bash or perl script via ssh on that remote server in the following fashion:
exec("ssh -o StrictHostKeyChecking=no -p $connectivity_port $user@$server \"bash -s\" -- &1", $result, $exit_code);
This all works perfectly fine, but it takes a while depending on the code being run. Since locally there's almost nothing to process except the output of the scripts (there is a lot of logging and some scripts output to files local the server the PHP is run from). ### The Goal ### I was wondering what the best/easiest method/tools would be, running from bash, to run the PHP script in parallel, making sure everything output is in the order of the servers in the lists (say, x servers at a time, maybe 10, to drop the execution time down) PHP itself does not seem to be the way to go from my research and version limitations, and bash seems to also not fit the bill, but I am open to being wrong, and willing to learn other methods.
Asked by solenoid (131 rep)
Nov 29, 2021, 10:31 PM
Last activity: Nov 30, 2021, 03:54 PM