chanakya has asked for the wisdom of the Perl Monks concerning the following question:
Greetings eveyone !!
I have a script which will look in a pre-defined log directory, gets the file names,
processes the files one by one and removes the processed file from the log directory.
Now, I want to split the processing of log files to multiple sub-processes, as the current processing takes longer time.
What I want to do is say, when X.pl executes, the X.pl will look into the log directory and gets
the file names in the log directory. For Example if X.pl finds 3 log files, then it
will fork 3 sub-processes of Y.pl and pass each of the log file as an input to the sub processes of Y.pl
The X.pl will have to wait until all the sub-processes returns. Once all the sub-processes return then the parent, i.e X.pl will get newer filenames and the process continues. And also the most important part is all the three sub-processes should run at the same time and not one after another.
Can anyone tell me how to implement the forking and parent script to wait until the sub-processes return.
I have a script which will look in a pre-defined log directory, gets the file names,
processes the files one by one and removes the processed file from the log directory.
Now, I want to split the processing of log files to multiple sub-processes, as the current processing takes longer time.
What I want to do is say, when X.pl executes, the X.pl will look into the log directory and gets
the file names in the log directory. For Example if X.pl finds 3 log files, then it
will fork 3 sub-processes of Y.pl and pass each of the log file as an input to the sub processes of Y.pl
The X.pl will have to wait until all the sub-processes returns. Once all the sub-processes return then the parent, i.e X.pl will get newer filenames and the process continues. And also the most important part is all the three sub-processes should run at the same time and not one after another.
Can anyone tell me how to implement the forking and parent script to wait until the sub-processes return.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Forking and running all child processes at the same time
by robartes (Priest) on Jun 06, 2005 at 12:30 UTC | |
Re: Forking and running all child processes at the same time
by Fletch (Bishop) on Jun 06, 2005 at 12:18 UTC | |
Re: Forking and running all child processes at the same time
by salva (Canon) on Jun 06, 2005 at 12:28 UTC | |
Re: Forking and running all child processes at the same time
by reneeb (Chaplain) on Jun 06, 2005 at 12:25 UTC | |
by tlm (Prior) on Jun 06, 2005 at 12:45 UTC | |
Re: Forking and running all child processes at the same time
by tlm (Prior) on Jun 06, 2005 at 12:33 UTC | |
by jimbojones (Friar) on Jun 06, 2005 at 14:34 UTC |
Back to
Seekers of Perl Wisdom