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

Re: Determine if script is already running

by guha (Priest)
on Mar 03, 2003 at 09:29 UTC ( [id://239977]=note: print w/replies, xml ) Need Help??


in reply to Determine if script is already running

As usually there is something to be learned from our mighty merlyn!

Check out this Web Techniques Column which IMHO is closely related to what your trying to achieve.

  • Comment on Re: Determine if script is already running

Replies are listed 'Best First'.
Re: Re: Determine if script is already running
by Nitrox (Chaplain) on Mar 03, 2003 at 14:01 UTC
    Abigail also suggested a persistent lock in her post and it's the direction I'm headed. Which brings me to another question:

    Are there any pitfalls to holding a lock for an extended period of time? (we're talking weeks here)

    -Nitrox

      Only one comes to mind: IMNSO, the only OSes I've seen that don't do better with weekly restarts are VMS and MVS (maybe OS/390, I haven't worked with it much.)

      Holding a lock for a week at a time and doing a controlled restart should be entirely safe under Windows NT 4.0 or later, any modern Linux, SCO, etc.

      Rather than re-inventing the wheel, are there parts of Big Brother or Nagios that could save you some coding time?

      Abigail: Thanks for the good idea, I've got a problem similar to Nitrox's in my current project and I like your solution an awful lot better than what I'm doing now. ++.

      --
      Spring: Forces, Coiled Again!
      Nitrox,
      As I indicated in my first post. Using a lock file by itself, regardless of type, will not guarantee only a single copy of a script is running in Unix. This is because it is possible to delete a file that is locked. Using the /tmp directory most likely increases the odds of deletion by its nature. The subsequent instance of the script is able to create and lock the new file - and now you have two copies running. You really need to have multiple methods for validation and checking the process table is a good place to start.

      Cheers - L~R

        This bugs me, why does *nix allow deletion of an open and locked file? On Win32 a file can't be deleted until the ref count == 0, is there a way to explicitly set this in *nix?

        -Nitrox

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2024-04-24 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found