Skip to content

Commit 4aee495

Browse files
run_batched.sh
1 parent 92d157b commit 4aee495

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tool/run_batched.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# usage: for ...; do echo cmd; done | run_batched.sh
4+
5+
MAX_JOBS=10
6+
7+
while true; do
8+
CUR_JOBS=$(jobs | wc -l)
9+
if ((CUR_JOBS < MAX_JOBS)); then
10+
read cmd || break
11+
echo "$cmd"
12+
bash -c "$cmd" &
13+
else
14+
sleep 60
15+
fi
16+
done
17+
18+
echo "scheduled all jobs"
19+
20+
wait $(jobs -p)

0 commit comments

Comments
 (0)