BASH ... Parallel to GNU

Expanding my brains and flushing Google to find a way to get a command semwith a timeout parameter to give me a timeout exit code. It doesn’t have to be through sem, it’s just a pain, because I need to end up applying actions in different ways depending on whether:

  • I get an OK response from a script that is being called

  • I get nothing but OK from the script that is being called

  • Call time

The semaphore is used in this case to switch calls to a script for which I pass a list of file names for the outgoing message queue. As you can see in the example of a rough test below, I can deal with the first two scenarios, but I can’t get anything for life that I can use from a process that ends in a timeout (i.e. outputtest.shhas sleep 6; echo testings)

sem --jobs 3 --timeout 3 -u \
'runproc=$(bash outputtest.sh q_xxxx); if [ "$runproc" == "00" ]; 
then echo "OK"; else mv ./q_xxxx ./err/err_xxxx; fi'

Any clues?

+4
source share
1 answer

The GNU Parallel waits until the semaphore is available, then it hangs in the background and starts the task - possibly killing it if it expires.

sem . sem , - - .

, , :

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

sem , --fg: 1, /timeout, .

--joblog, ( -1 15 ). sem, , parallel ( --semaphore).

, : http://www.gnu.org/software/parallel/man.html#example__gnu_parallel_as_queue_system_batch_manager

+5

Source: https://habr.com/ru/post/1531880/


All Articles