For (loop)

From Anthony Pastor Wiki Notes - Verba volant, scripta manent
Revision as of 08:31, 22 April 2017 by Anthoanthop (talk | contribs) (Created page with "== Exec a script on a 10 servers batch, pause and continue the loop following this scheme == <syntaxhighlight lang="bash"> i=1 for h in server{1..1000}; do ssh -o UserKn...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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