-1

I've done a lot of googling but not found why this doesn't work (all variables defined earlier in code):

shell_exec("curl https://$domain/testscript.php?o=".strval($num1)."&t=".strval($num2)." > /dev/null 2>&1 &");

The script gets executed but my calling scripts remains unresponsive until completion, defeating the whole purpose.

Most examples I find use a direct call to the php interpreter but I'm unable to use that method because:

  1. the query strings don't then work
  2. I get a lot of errors due to relative paths which I cannot easily resolve
user1729972
  • 712
  • 2
  • 9
  • 29

1 Answers1

0

A level of indirection solved this: instead of using shell_exec to invoke cURL as above, I placed it within a script. Then used shell_exec to execute that intermediate script with the php compiler.

The web-page is instantaneously responsive with the long-running process completing much later in the background.

user1729972
  • 712
  • 2
  • 9
  • 29