BASH...GNU Parallel BASH...GNU Parallel shell shell

BASH...GNU Parallel


GNU Parallel waits until a semaphore is available, then it forks into the background and runs the job - possibly killing it if it times out.

So sem returns before the job is done and before it is timed out. Therefore sem cannot tell you whether the job will fail or time out at some later point in time.

A possible workaround is having a canary so you can see if the job completes or not:

rm canarysem 'your_job; echo the job completed > canary'

If the sem is started from different parallel running scripts, then --fg may be your solution: It will block until the job has finished and give an exit value of 1 if the job fails/timesout, but other parallel running scripts will be able to use the same semaphore.

An alternative would be --joblog from which you can read the exit value (A timeout would give -1 and 15 as signal). But that does not work well with sem, so you would have to rewrite your program to use parallel (without --semaphore) instead.

To process a message queue you might want to look this for inspiration: http://www.gnu.org/software/parallel/man.html#example__gnu_parallel_as_queue_system_batch_manager