Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Scheduling Perl Tasks

by marioroy (Prior)
on Mar 24, 2017 at 08:30 UTC ( [id://1185729]=note: print w/replies, xml ) Need Help??


in reply to Re: Scheduling Perl Tasks
in thread Scheduling Perl Tasks

Greetings.

The project is completed including a release on CPAN. To ensure a given script is executing once, the following is how to do it using Mutex. That will block until obtaining an exclusive lock. A false value is returned if the timeout is reached, and a true value otherwise.

use Mutex; my $mutex = Mutex->new( path => $0 ); # terminate script if a previous instance is still running exit unless $mutex->timedwait( 2 ); ...

Regards, Mario

Edit: Updated the CPAN link to point to the 1.001 release.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found