$lifelimit){ if($lifetime > $lifelimit){ unlink($filename); //Suppress if exist and too old } $file=fopen($filename, "w+"); // Create lockfile if($file == false){ die("file didn't create, check permissions"); } /* Your process */ unlink($filename); //Suppress lock file after your process }else{ exit(); // Process already in progress }