Maybe:
parallel -j0 check ::: $pid1 $pid2 $pidN &&
echo all succeeded
parallel -j0 '! check' ::: $pid1 $pid2 $pidN &&
echo all failed
parallel -j0 --halt soon,success=1 check ::: $pid1 $pid2 $pidN &&
echo one succeeded
parallel -j0 --halt soon,fail=1 check ::: $pid1 $pid2 $pidN ||
echo one failed
It will run the checks in parallel. Replace soon
with now
if you want running checks to be killed as soon as we know the result.
If you have the PIDs as output from a pipe (one per line):
pid_generator | parallel -j0 check && echo all succeeded
parallel
gives one value to check
and runs as many check
as possible in parallel (-j0
).
If the server does not have parallel
installed, run this on a machine that has parallel
installed:
parallel --embed > new_script
Edit new_script
(the last 5 lines) and copy the script to the server.
all
in this case; just interested in both (and of course negatingany
can give the effect ofall
) – alexis Oct 16 '19 at 15:21