Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 ( #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
Node Status?
node history
Node Type: note [id://810710]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2019-12-12 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?