My intention is this.
My client.html calls a php script check.php via ajax. I want check.php to check if another script task.php is already being run. If it is, I do not
You can realize it, using lock file:
if(is_file(__DIR__.'/work.lock')) { die('Script already run.'); } else { file_put_contents(__DIR__.'/work.lock', ''); // YOUR CODE unlink(__DIR__.'/work.lock'); }