Skip to content

Instantly share code, notes, and snippets.

@CMAD
Created July 9, 2012 18:02
Show Gist options
  • Save CMAD/3077918 to your computer and use it in GitHub Desktop.
Save CMAD/3077918 to your computer and use it in GitHub Desktop.
./parallel.sh $WORKER_CMD $NUM_WORKER $TASK_POOL
#!/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
@CMAD
Copy link
Author

CMAD commented Jul 9, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment