Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Flock and Subroutine

by Khen1950fx (Canon)
on Mar 05, 2010 at 07:17 UTC ( [id://826899]=note: print w/replies, xml ) Need Help??


in reply to Flock and Subroutine

I tried this:
#!/usr/bin/perl use strict; use warnings; $|=1; use Sys::RunAlone; print "Script $0 is running now.\n"; die "Another $0 is already running.\n" unless open my $self, '<', $0; CheckRaceCondition(); sleep(5); print "End.\n"; sub CheckRaceCondition { die "Another $0 is already running.\n" unless open $self, '<', $0; } __END__
For an in-depth discussion of Fcntl and flock see:

Ensuring only one copy of a perl script is running.

Then, for a great solution to the problem by ikegami, see:

Re^2: Ensuring only one copy of a perl script is running

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found