Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Forking and running all child processes at the same time by chanakya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2022-12-09 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?