Running a php script with a cron job, how can I do to have only one instance
of the script running ?
Thanks for any answer.
Nicolas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the
There may be a much easier method however why not write a file and then check for it's
existence on the next execution. Delete the file at the end of
execution to clear the way for the next pass.
Quick and dirty so probably at least on typo
?
$pidFile = path/to/file/filename;
if (!is_file
Hello Jerry,
Friday, December 28, 2001, 5:37:39 PM, you wrote:
JVU Pseudo code:
JVU check if pid file exists
yes - DIE
no - write pid file
JVU At end of script
JVU delete pid file
This code can't guarantee the result. Use file locking instead.
JVU -Original Message-
JVU From:
Under *nix - SysV semaphores
HTH
Regards,
Andrey Hristov
- Original Message -
From: Nicolas Guilhot [EMAIL PROTECTED]
To: Php General MailingList [EMAIL PROTECTED]
Sent: Friday, December 28, 2001 4:31 PM
Subject: [PHP] Only one instance of a script at a time !
Running a php script
I was thinking about this solution, but what can I do if the script ends
prematurely. The file will never be deleted ??
Anybody has an example of how to use flock ?
Nicolas
Gerard Onorato [EMAIL PROTECTED] a écrit dans le message news:
[EMAIL PROTECTED]
There may be a much easier method
Nicolas,
You could try something like
?
$pifFile = /path/to/file/filename;
if(file_exists($pifFile))
{
$fp = fopen($pifFile, r);
flock($fp, 2);
// your code
fclose($fp);
}
Note: Just wrote it, not tested.
Note: You would probably want to do somethig more graceful then simply
* Nicolas Guilhot ([EMAIL PROTECTED]) [Dec 28. 2001 10:00]:
I was thinking about this solution, but what can I do if the script ends
prematurely. The file will never be deleted ??
It's a nasty hack, but you chould run a separate shell script to
check for the existance of the running script,
7 matches
Mail list logo