Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Nov 2006 12:00:34 +0100
From:      nicky <nicky@valuecare.nl>
To:        Andrew Pantyukhin <infofarmer@FreeBSD.org>
Cc:        freebsd-questions@FreeBSD.org
Subject:   Re: Parallel shell scripts.
Message-ID:  <4551B8D2.3020502@valuecare.nl>
In-Reply-To: <cb5206420611080221n3fde2772h3569a8ce8f9920dc@mail.gmail.com>
References:  <4551AC4A.2000108@valuecare.nl> <cb5206420611080221n3fde2772h3569a8ce8f9920dc@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Andrew Pantyukhin wrote:
> On 11/8/06, nicky <nicky@valuecare.nl> wrote:
>> I have to start 2 processes in the background (running in parallel),
>> capture their return codes and after all 4 have completed successfully i
>> want to continue with the main script.
>
> What do you need their return codes for? If you
> only want to display them, something like this
> might help:
>
> (/bin/proc1;echo "Proc 1 exited with status $?) &
> (/bin/proc2;echo "Proc 2 exited with status $?) &
> wait
>
> In general, retrieving exit statuses of multiple
> general is not trivial. I.e. you need some kind of
> IPC for that, at least store statuses in some tmp
> files and read it back from the main process.
>
>
The whole idea is this. I have to extract two different databases to csv 
files. One takes about an 1 hour, the other 1.5 hours. The problem is my 
time window, which is 2 hours. So extracting one after the other is not 
an option. After both extractions are complete, it should load the csv 
files into a target database.

I figured it would be best to launch the two extraction processes in a 
child process and just let the main process wait till they are complete. 
It should then check if the extraction processes completed successfully 
and proceed to load the data into the target database.

My concept script seems to work, but i'm dubious about something. If 
childprocessA takes longer then childprocessB. The main script is still 
waiting for childprocessA, while childprocessB has already completed 
it's run. So, if i am correct, the PID of childprocessB does not exist 
anymore. So calling 'wait [childprocessB pid]', would it always return 0 
or will it still return the actual return code?

This just makes me doubt if my concept script is the proper solution for 
my problem.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4551B8D2.3020502>