I have a usecase where i have to excute some commands which are long running, so i have to run 3-6 commands in parallel so that i will finish in as fast as possible.
Below is my code snippet:
#!/bin/sh
executeCommand(){
//command which will run for almost 2-3 min
}
executeCommand 1 &
P1=$!
executeCommand 2 &
P2=$!
executeCommand 3 &
P3=$!
wait $P1 $P2 $P3
What i observed when running this block, P3 runs first and then after 30 sec, P2 and P3 ran at same time. I actually need to start all at once only so that it finish as fast as possible.
Below is my machine configuraions: EC2 instance : p3.2xlarge(8vCPU's, 61GB RAM,1 Nvidia Tesla V100 GPUs, 16 GPU Memory (GB))
Can someone suggest what is best to run all command at once?
Thanks in advance
timeout 10 yes "$1"
)? – A.B Mar 18 '21 at 15:47like timeout 10 yes "$1"
)? – A.B Mar 19 '21 at 08:43wait ...
withwhile : ;do ps -fp$P1,$P2,$P3 ;sleep 1;done
to debug. Readman ps
. – waltinator Mar 19 '21 at 17:02