I have a problem with shell_exec. I try to run the other php file in a separate thread, according to this answer: https://stackoverflow.com/a/222445/1999929 I have this very-very simple code:
<?php
$realpath = realpath("./second.php");
file_put_contents("./log.txt","\nFirst php running!\n",FILE_APPEND);
shell_exec("php $realpath > /dev/null 2>/dev/null &");
?>
I need this because i want to use this file for a dropbox webhook link, and it has to give a response in 10 seconds, while processing the changed files sometimes takes more time. So this file has to tell te other to run, and give a response, while not waiting for the other to finish.
When shell_exec is used in the code, the text is outputted infinite times in the file, without it its working fine, but i need to call the other file somehow.
EDIT - I tried exec() too, because the answer above used it instead of shell_exec, results are the same.