in reply to Scheduling Perl Tasks

Greetings 9mohit2,

I put together a Fcntl-based (flock) advisory locking module posted here. Any Perl toolbox might want this.

I'm sorry, but lack the time making modules for CPAN. This is my contribution to the Perl community. Thanks all. I love PerlMonks and enjoyed posting solutions from time to time.

Regards, Mario

Replies are listed 'Best First'.
Re^2: Scheduling Perl Tasks
by marioroy (Prior) on Mar 24, 2017 at 08:30 UTC

    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.