I have a bash script that connects to servers via SSH to run a command. The script gets the IP address from a file.

Problem: if I have 500 IPs in the file, I don't want to simultaneously open or try to open 500 connections. I want to do, lets say, 10 at a time in order to save resources.

How do I run the command via SSH 10 servers at a time?

Here is my script:

```
#/bin/bash

nodes="big_list_of_nodes.txt"

while read node; do
   # Running in background
   (uptime=`ssh -o ConnectTimeout=5 $node uptime 2>&1`
   if [ $? -eq 0 ]; then
      echo "$node uptime: $uptime"
   else
      echo "Connection timeout for node $node"
   fi) &
 done < $nodes
 # Wait for all jobs to finish    
 wait

```