Reputation: 189
Is it possible to set a -halt condition (or multiple -halt conditions?) such that all jobs will be halted if any of them fail, regardless of the exit code?
I want to monitor for an event (that I just triggered, separately, on a load balanced service). I can identify if the event passed or failed by viewing the logs, but I have to view logs on multiple servers at once. Perfect! Parallel it! I have an extra requirement though: I want to return success or failure based on the log result.
So I want to stop the parallel jobs if any of them detect the event (i.e. "-halt now"
) but I don't know if the detect will return zero or non-zero (that's the point: I'm trying to find out that information) so neither "--halt now,success=1"
nor "--halt now,fail=1"
is correct, I need to figure out a way to do something like "--halt now,any=1"
)
I did a look through the source and, well, my perl Kung-fu is inadequate to tackle this (and it looks like exitstatus is used in many different places in the source, so it's difficult for me to figure out if this would be feasible or not.)
Note that ,success=1
and ,fail=1
both work perfectly (given the corresponding exit status) but I don't know if it will be success or fail before I run parallel.
Upvotes: 5
Views: 3807
Reputation: 61
The GNU Parallel manpage says:
--halt now,done=1
exit when one of the jobs finishes. Kill running jobs.
Source: https://www.gnu.org/software/parallel/man.html (search for --halt
- it's a big page)
Upvotes: 6
Reputation: 33715
If you (as a human) are viewing the logs, why not use Ctrl-C?
If you simply want all jobs to be killed when the first finishes, then append true
to your command to force it to become a success:
parallel -Sserver{1..10} --halt now,success=1 dosomething {}\;true ::: 1..100
Upvotes: 2