Guest User

Untitled

a guest
Oct 17th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. check_if_failed() {
  4. local _status="$1"
  5. if [ ! "$_status" = 0 ]
  6. then
  7. echo "FAILED!"
  8. exit 1
  9. fi
  10. }
  11.  
  12. pids=()
  13.  
  14. for host in $hosts
  15. do
  16. ssh -o ConnectTimeout=2 $host "
  17. set -e
  18. which parallel
  19. sleep 1
  20. " &
  21. pids+=("$!")
  22. done
  23.  
  24. for pid in "${pids[@]}"
  25. do
  26. wait "$pid"
  27. check_if_failed "$?"
  28. done
  29.  
  30. echo "All is good!"
  31. exit 0
Add Comment
Please, Sign In to add comment