Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: singleton lock not reliable

by LanX (Saint)
on Jun 24, 2021 at 08:45 UTC ( [id://11134249]=note: print w/replies, xml ) Need Help??


in reply to singleton lock not reliable

Some remarks
  • Your lockfile's path will be relative to your current working directory. I'd suggest using an absolute path to avoid miscommunications.
  • Your sleep is called without argument, which means it'll sleep forever.
  • Are you sure that a parallel instance should exit? Without LOCK_NB it would wait till the lock is free.
  • You are not using parens for your arguments for flock(), precedence issues with | would make me nervous here. I'd need to look it up...
    it should work in this case tho.
Regarding debugging

You shouldn't rely on ps for debugging, append with >> to (another) absolute_path/logfile when your script is

  • started,
  • exiting,
  • working,
  • stopped,
including process ID and timestamp.

Please come back if you can really reproduce a problem.

Maybe of help:

File lock demo

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

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

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

    No recent polls found