$escaped_check = escapeshellcmd("/usr/bin/php -f /opt/status/check.php " . $_SERVER['REMOTE_ADDR'] . " >> /dev/null 2>&1 &");
shell_exec($escaped_check);
I am trying to execute the above code in the background for the sake of non-blocking thread, but I am not sure how to exit the check.php when the job is done.
you can popen instead of shell_exec.
Then you can terminate it by proc_terminate
Or you can obtain process id by calling proc_get_status.
With PID you can terminate process also.
I hope this helps.