Run multiple ssh commands in parallel with GNU Parallel 2


Every true sysadmin has been in this predicament — “I need to run this command on a bunch of machines.” The typical approach is to create a for loop, and run the command serially. This works well, but if a) you have tons of hosts, or b) the command takes a while to run on each machine, you may be looking for something a bit more efficient.

Here’s an example that gets a list of hosts using aws-cli, and restarts httpd on them. In your case, update the command and key path as needed.


Leave a comment

Your email address will not be published. Required fields are marked *

2 thoughts on “Run multiple ssh commands in parallel with GNU Parallel