in reply to Best way to synchronise scripts


What may be best for me may not be best for you. Heck, I've done that in at least three different ways, none of which are likely to be considered "best" by at least a handful of others, probably many others.

I've done forking/execing/waiting by hand. I've used Parallel::ForkManager (in the child you can simply exec your proc_script and then $pm->wait_all_children after you're done forking them all off). Most recently, I've adopted AnyEvent to manage this. And I'm looking at AnyEvent::Fork and friends (e.g., AnyEvent::Fork::RPC) for the future.

Proc::JobQueue also looks interesting, though it might be a bit heavy for what you're doing.

These all have pros and cons, so it really depends on what you want to do. I suspect that Parallel::ForkManager might be the easiest solution that I'm familiar with for Doing The Right Thing for you. Because you don't really want to fork off a separate script for each file all at the same time. Parallel::ForkManager is one solution (of at least a few, I'm sure) that can make it easy to ensure you don't have too many going at a time by placing a limit on how many forks are running at a time.