<?php $lockFile = '/tmp/myscript.lock';// Check if the lock file existsif (file_exists($lockFile)) {// Exit if the script is already runningexit("Script is already running.\n");}// Create the lock filefile_put_contents($lockFile, getmypid());// Register shutdown function to remove the lock file when the script finishesfunctionremoveLockFile() {global$lockFile;if (file_exists($lockFile)) {unlink($lockFile); }}register_shutdown_function('removeLockFile');// Your script logic heresleep(30); // Simulate a long-running task