[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Edlug Archive Mar 2004 ]

Re: [edlug] Perl - Only run n instances of script?



On Thu, Mar 11, 2004 at 10:32:50AM +0000, Lee Kindness wrote:

> Anyone got a quick way of limiting/locking a script so that it can
> only be run, for example, 4 times concurrently? Any other runs of the
> script would block until a "slot" was available.

  Touch a file in the BEGIN { } block, and then remove it in the DESTROY
 {} section.

  Then upon initialization count the number of files /var/run/foo.$$.

  That's a simple solution that should work fairly well, requires no
 IPC and is not perl specific.

  Perhaps if you explained what it is that you're trying to do you'd get
 a more specific answer.

Steve
--
-
----------------------------------------------------------------------
You can find the EdLUG mailing list FAQ list at:
http://www.edlug.org.uk/list_faq.html



This archive is kept by wibble@morpheux.org.DONTSPAMME
homepage