Created
July 9, 2012 18:02
-
-
Save CMAD/3077918 to your computer and use it in GitHub Desktop.
./parallel.sh $WORKER_CMD $NUM_WORKER $TASK_POOL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
WORKER_CMD="$1" | |
NUM_WORKER="$2" | |
TASKS_POOL="$3" | |
callback(){ | |
"$WORKER_CMD" "$1" | |
schedule | |
} | |
schedule(){ | |
TASK=`head -n 1 "$TASKS_POOL"` | |
sed -i 1d "$TASKS_POOL" | |
if [ -z "$TASK" ]; then | |
return | |
fi | |
callback "$TASK" & | |
} | |
for i in `seq "$NUM_WORKER"`; do | |
schedule | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Este es un script viejo que use un par de veces para sincronizar cuentas de correo, pasa a NUM_WORKERS, el siguiente TASK de TASK_POOL, cuando un WORKER termina, inmediatamente se lanza un nuevo WORKER, feo pero choto.