1

I need to call a Java program in parallel threads from a unix shell script and wait for all the threads to complete. Then the return status (either 1 or 0) of each thread should be captured. if all the parallel threads are sucecssful, unix script will return SUCCESS else if at least one of the threads has errroed, then return FAIL. I found this code snippet on google which is very relevant to what I was looking for.

    for count in {1..10}
    do
        call_process $count $runid &
        JPID="$JPID $!"
    done
    for pid in $JPID; do
        wait $pid || let 'RESULT+=1'
        echo "RESULT - $RESULT"
    done

function call_process {
    java -Djava.security.egd=file:/dev/urandom -Xmx8192M -Dfile.encoding=ISO-8859-1 com.load.MainProg $1 $2
}

But here the result of the Java process is not captured. Is it possible to capture the java return status as well for each process id?

1 Answer 1

1

For parallel processing from shell use GNU Parallel available in all major distros. Check https://stackoverflow.com/a/6789085/2235381 and https://www.gnu.org/software/parallel/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.