Hi. I'm trying to check if a process is already running by using a temporal file demo.lock:
demo.php:
<?php
$active=file_exists('demo.lock');
if ($active)
{
echo 'process already running';
}
else
{
file_put_contents ('demo.lock', 'demo');
sleep(10); //do some job
unlink ('demo.lock');
echo 'job done';
}
?>
however it doesn't seem to work: if I open demo.php twice it always shows "job done", maybe because it considers it the same process? is there some way to do it? I also tried with getmypid() with similar results.
Thanks