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

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

by bliako (Monsignor)
on Dec 05, 2022 at 23:25 UTC ( [id://11148591]=note: print w/replies, xml ) Need Help??


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

why re-invent the wheel when there is already Proc::ProcessTable which you can enquire about your current processes? (and this approach was already mentioned in your previous question, see Re: Mechanism for ensuring only one instance of a Perl script can only run?)

Secondly, you hardcode /usr/bin/perl in the shebang and also in the script but those who will inherit the script will know that? And you assume that who runs the script will do it without appending it with a perl interpreter executable.

Thirdly, "simpler" may be but does it work under all conditions and circumstances? Hmmm. I would say, stick either with flock/highlander or with the shared-memory approach of Script::Singleton (my preference is with the memory-based approach which is more universal than the file-system approach).

Btw, if( index($line,$dirPerl) != -1  &&  index($line,$name) != -1 ) can be replaced with a regex

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:17 UTC
    Thanks bliako, Appreciate all that you say. I couldn't get the Proc::ProcessTable approach to work, sadly. My flock/highlander attempt ran into problems, too, which is why I'm back with more desperate ideas. I like the look of Script::Singleton, perhaps I'll try that next.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-19 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found