I'm having a shell script as follows.
#!/bin/bash myfunc() { #do something (call a rest service) sleep 300 status=$(get status of the operation performed above) while [ "$status" != "succeeded" ]; do #do something (call a rest service) sleep 300 status=$(get status of the operation performed above) done } a=0 while [ $a -lt 1000 ] do a=`expr $a + 1` myfunc done In best case, above script takes at least 5*1000=5000 seconds to complete running.
Is there a way to make the myfunc call parallel so that we can let the while loop to spawn multiple running instances of the myfunc??
Note: Somehow, this script should wait until all instances of myfunc executions are completed.
export -f myfunc; seq 1000 | xargs -P0 bash -c myfuncexport -f myfunc, runparallel myfunc ::: {1..1000}