The Perl wrapper below executes commands in parallel, saving STDOUT and STDERR to /tmp files:
open(A,"|parallel");
for $i ("date", "ls", "pwd", "factor 17") {
print A "$i 1> '/tmp/$i.out' 2> '/tmp/$i.err'\n";
}
close(A);
How do I obtain the exit status values from the individual commands?
GNU Parallel 20110722 has exit val and signal in
--joblog
:If you want to avoid the wrapper you could consider:
Version 20110422 or later makes it even shorter:
If your lines do no contain ' then this should work too:
Instead of wrapping
parallel
, you can use any of the tons of modules available from CPAN providing similar functionality.For instance:
To get the exist status of the individual jobs,
parallel
would need to write the info somewhere. I don't know if it does or not. If it doesn't, you can do that yourself.Update: I went and installed
parallel
.It has an option called
--joblog {file}
which produces a report with exit codes. It accepts-
for file name if you want it to output to STDOUT.Note that
parallel
doesn't recognise abnormal death by signal, so this is not included in the--joblog
report. Using the solution I posted above, a missing .exit file would indicate an abnormal death. (You must make sure it doesn't exist in the first place, though.)