in reply to One hand on the Throttle

I have an idea for an alternative approach, but I haven't actually tested it — I'm currently not even in a position to test it. Take a look at PPerl... If I interpret it correctly, there's one master copy of your script running, no matter how many you launch via a command line (shell). pperl in turn controls and launches forks of your running script.

There is the problem of variables shared between all your scripts. Problem? No, in this particular case, you can make good use of it, and use one common variable to count how many copies are running. Each instance of your script should increment that variable, and decrement it when it exits. If there are too many already, exit immediately.