I think that a simple solution could be to have a process handle file. Do the following:

Create a text file, with six lines, each containing the word HANDLE.

Next, when your script executes, it should:

* Lock the handle file.
* Open the handle file.
* Read in the handle file.
* If there are no "HANDLE"s left, exit.
* If there are "HANDLE"s left, pop one off the bottom of the file.
* Write out the file.
* Close it.
* Unlock it.

Then do whatever work you intended to do within the script. Upon completion of the work, do the following:

* Lock and open the HANDLE file.
* Push your HANDLE back into the end of the file.
* Close and unlock the file.
* exit.

Oh, and if it finds HANDLE file already locked, just wait a second and try again.

It's a pretty simple method. If you want to increase or decrease the number of simultaneous processes, you just alter the number of handles in the file. ...the file could just as easily contain a counter number instead of a series of "handles". Each process decrements the counter, runs, then increments the counter. If the counter ever hits zero, no more processes can run. Same basic concept.

Dave

"If I had my life to do over again, I'd be a plumber." -- Albert Einstein


In reply to Re: Maximum # of concurrent runs by davido
in thread Maximum # of concurrent runs by warthurton

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.