Racking my brains and scraping Google to find a way to get the sem
command with timeout option to give me an exit code on timeout. It doesn't have to be through sem
, it's just a pain because I need to end up applying actions differently based on whether:
I get an OK response from the script being called
I get anything but OK from the script being called
The call times out
The semaphore is used in this case to throttle calls to a script which I pass a list of filenames to for an outgoing message queue. As you can see in the rough test example below I'm able to able to deal with the first two scenarios, but I can't for the life of me get anything outputted that I can use from the process being terminated by timeout (i.e. outputtest.sh
has 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 hints?