Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Ensure Only One Instance of Your Script is Running... with 'ps -ef' ?

by hippo (Bishop)
on Dec 05, 2022 at 23:33 UTC ( [id://11148592]=note: print w/replies, xml ) Need Help??


in reply to Ensure Only One Instance of Your Script is Running... with 'ps -ef' ?

I implemented this idea, but ran into management issues with the lock file. (The lock file was not deleted properly, it was overwritten, etc.)

Neither of these situations is a problem. The lockfile is only there to be locked. If it is absent, then there is no lock. If it is present a lock should be attempted. The contents of the file (if any) are irrelevant.

You have presented an alternative which is, by comparison, brittle. It relies on shelling out a lot and we know from experience that this can lead to problems.

If managing your own lockfiles with flock is too tricky then why not simply use Script::Singleton as stevieb suggested here? That's a simple, reliable solution.


🦛

  • Comment on Re: Ensure Only One Instance of Your Script is Running... with 'ps -ef' ?

Replies are listed 'Best First'.
Re^2: Ensure Only One Instance of Your Script is Running... with 'ps -ef' ?
by redapplesonly (Sexton) on Dec 06, 2022 at 15:10 UTC
    Thanks hippo, Appreciate you ruling that my second solution is "brittle"; that's the kind of expertise I lack and why I like this site so much. Appreciate the advice! I'm looking into Script::Singleton, as that sol'n looks perfect...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found