Using a lockfile would seem simplest. See eg. Re: reliable lockfiles? (lock)
In reply to Re: perl script and queue by hippo in thread perl script and queue by k_manimuthu