Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by moritz (Cardinal)
on Dec 03, 2009 at 08:54 UTC ( #810783=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 think Cron:: is a bad top level namespace when the module is not specific to cron at all.

What about using Process:: instead? Something like Process::AvoidConcurrentRuns or Process::AvoidMultipleInstances or Process::Singleton

Also if you put this on CPAN, you might think about different possible use cases:

  • Users might want to use it exactly as you have shown
  • Users might want to use it as you've shown, but without the verbose output
  • Users might want to just query if another instance is already running, and behave as they see fit
The interfaces for that might look like this:
# first case: use Process::Singleton qw(:auto_verbose); # second case: use Process::Singleton qw(:auto); # third case: use Process::Singleton qw(is_running); if (is_running()) { ... } else { ... }

This is of course just an example, but I want to encourage you to think more about the interface.

  • Comment on Re: RFC: A new module to help avoid running multiple instances of the same script (via cron, for example)
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2019-12-15 02:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?