comparison lemuriformes/waiter.sh @ 17:4793f99b73e0

[lemuriformes] utility functions
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 Dec 2017 17:42:52 -0800
parents
children
comparison
equal deleted inserted replaced
16:9b1bb9eee962 17:4793f99b73e0
1 #!/bin/bash
2
3 # parallelize and wait for a set of jobs;
4 # it's MapReduce for `bash`!
5
6 FAIL=0
7
8 # See http://jeremy.zawodny.com/blog/archives/010717.html
9
10 {{for command in commands}}
11 {{command}} &
12 {{endfor}}
13
14 # wait for processes
15 for job in `jobs -p`
16 do
17 echo ${job}
18 wait ${job} || let "FAIL+=1"
19 done
20
21 if [ "${FAIL}" == "0" ]
22 then
23 exit 0
24 fi
25
26 echo "${FAIL} failing job(s)"
27 exit 1