[PHP] Re: Ensure only one instance of a script is running

2005-03-20 Thread zini10
a more reliable solution: Write a lock file and update timestamp each minute or so ,(at varous places around the script) then in order to check if the script is already runninh, check the timestamp. "Jeremiah Fisher" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Test for a lock

[PHP] Re: Ensure only one instance of a script is running

2005-03-17 Thread Jeremiah Fisher
Test for a lock file when the script starts, and remove it when the script ends. This isn't 100% reliable, but it's the typical solution to this problem. If the script fails, the lock file may not be removed (ever have a Mozilla browser crash and tell you the default profile is locked?), so be

[PHP] Re: Ensure only one instance of a script is running

2005-03-16 Thread Raj Shekhar
"Mikey" <[EMAIL PROTECTED]> writes: > > How about grabbing the output from `ps -ax` and looping thourhgthe results > to see if your script is being run? Again the problem is of atomicity. This is a multi step process - do a ps -aux - do a grep on the output - start script processing What if

RE: [PHP] Re: Ensure only one instance of a script is running

2005-03-16 Thread Mikey
[snip] > Unluckily, this will not prevent a race condition. The only > file operations that are guaranteed to be atomic are mkdir() > and symlink(). Try to create the directory and see if it > fails. Also remember to rmdir() the lock directory before exiting How about grabbing the output from

[PHP] Re: Ensure only one instance of a script is running

2005-03-16 Thread Raj Shekhar
"Jay Blanchard" <[EMAIL PROTECTED]> writes: > [snip] > I have a script that inserts data from files uploaded to our server. I > need > to make sure that only one instance of this script runs at anyone time, > can > anyone tell me how I can do this? > [/snip] > > Don't run another instance. ba-d