>>>>> "BenBart" == BenBart  <[EMAIL PROTECTED]> writes:

BenBart> How do I prevent multiple instance of the same script from running?

Use the "highlander" solution:

    #!/usr/bin/perl

    BEGIN {
      use Fcntl ':flock';
      flock DATA, LOCK_EX | LOCK_NB or exit 0; # I'm already running
    }

    [ rest of your script here ]

    __END__

To do this, you must have __END__ at the end of your script, or else DATA
is not opened.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to