>>> sender: "Alex 'CAVE' Cernat" date: "Mon, Feb 05, 2007 at 08:41:57PM +0200"
>>> <<<EOQ
> [..]
> Ce m-ar interesa ar fi niste exemple de cum se face in bash (nu stiu
> daca se poate) [..]
Ceva in genul asta nu ar merge?
=== fork fun in bash ===
#!/bin/bash
# Max 'threads'
MAX=3
function next_worker() {
# Some way to retrieve the unique ID/data/whatever for each worker
echo $RANDOM
}
function do_work() {
local WORKER_ID=$1
echo "Doing work for ${WORKER_ID}..."
sleep $[$RANDOM % 6]
echo "Done for $WORKER_ID"
}
while :; do
if [ `jobs|wc -l` -le $MAX ]; then
do_work `next_worker` &
else
sleep 2
fi
done
=== done with fun ===
Numai bine,
Alex
_______________________________________________
RLUG mailing list
[email protected]
http://lists.lug.ro/mailman/listinfo/rlug