Is it possible to initiate 10 of the same shell scripts which also initiate more copies, and have them all use the same env variable?
For example:
script.sh:
#!/bin/bash
export COUNTER=$((COUNTER+1));
echo $COUNTER;
sleep 5;
/script.sh
using xargs -P 10 script.sh
results in each instance creating its own scope, rather than sharing the same $COUNTER variable
I'm essentially trying to deploy script.sh
10 initial times, and then when each one completes, it automatically executes script.sh
again, only this time with the newly incremented $COUNTER
variable.
I've asked a similar question here, and now understand why my previous method does not work, I'm extremely interested in learning what the best way to actually accomplish this will be.