For (loop)

From Anthony Pastor Wiki Notes - Verba volant, scripta manent
Jump to navigation Jump to search

Exec a script on a 10 servers batch, pause and continue the loop following this scheme

i=1
for h in server{1..1000}; do
    ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $h "screen -dmS my_script /tmp/scripts/my_script.sh"
    if (( i % 10 == 0 )); then # Pause 25mns every 10 iterations.
        sleep 1500
    fi
    let "i++"
done