Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)

by JavaFan (Canon)
on Dec 02, 2009 at 23:43 UTC ( [id://810710]=note: print w/replies, xml ) Need Help??


in reply to RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)

I often use:
use Fcntl qw !LOCK_EX LOCK_NB!; die "Another instance is already running" unless flock DATA, LOCK_EX|LOCK_NB; ... your code here ... # Don't forget __END__ or __DATA__ __END__
Note that file locking solutions only prevent concurrent running on the same OS instance. If the job can be run from different machines, but you want to prevent concurrent runs from different boxes, you'll need a different solution. (Acquiring a database lock for instance).
  • Comment on Re: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://810710]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found