PHP: exec() doesn't run in the background even with “>/dev/null 2>&1 &”

前端 未结 7 985
迷失自我
迷失自我 2021-01-04 10:59

I\'m calling this in my php script:

    exec(\"gutschein.php >/dev/null 2>&1 &\");

Calling the script (generates a pdf and s

相关标签:
7条回答
  • 2021-01-04 11:58

    The browser is might waiting for a response, so let your script produce any output and terminate the "main process". a simple

    die('ok');
    

    should do the job.


    btw, forking a new process by calling exec is might not the best solution since the new process isn't a real child process - means you can't control it. you might consider using pcntl (http://php.net/manual/de/book.pcntl.php) for this purpose. but stand clear, this extension has also his pitfalls, especially in the context of a webserver.

    0 讨论(0)
提交回复
热议问题