If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > stopping main shell when jobs go wrong

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-04-06, 09:29
ducasio ducasio is offline
Registered User
 
Join Date: Aug 2004
Location: Rome, Italy
Posts: 81
Question stopping main shell when jobs go wrong

hi friends,
I would like to trap the error exit status of the background jobs run from a main shell script. So I have run.myjobs.sh:
----------------------------------
for i in 1 2 3 4 5
do
my.job.sh &
done
---------------------------
how can I test whather any of the jobs finishes with exit status !=0 ? The jobs must be run in background.

Thank you in advance,
ducasio
Reply With Quote
  #2 (permalink)  
Old 09-04-06, 12:13
ducasio ducasio is offline
Registered User
 
Join Date: Aug 2004
Location: Rome, Italy
Posts: 81
hi guys,
actually I found a solution:
------------------------------------
ind=0
for i in 1 2 3 4 5
do
ind=`expr $ind + 1`
my.job.sh &
RC_ARRAY[$ind]=$!
done

for i in ${RC_ARRAY[*]}
do
wait $i
RC=$?
if test $RC -ne 0
then
echo "ERROR: Return Code = $RC"
exit $RC
fi
done
-------------------------------------

But I am interested to know if there's any other way to manage the situation with job controls or with trapping the child process.

thank you again,
ducasio
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On