Use php to trigger another php script, then ignore

北城余情 提交于 2019-12-09 16:57:52

问题


What I'm trying to work out how to do is this: I've got a php file let's call trigger.php that runs some php code that sets off another php file we'll call backgroundProcess.php to start processing.

Although trigger.php needs to ignore what happens to backgroundProcess.php, it just has to start it processing and it will stop while backgroundProcess.php keeps going.

edit1

I'm running this on Windows Wampserver 2.1 So this has to be a windows command.

edit2

Solved it with the following command, thanks to jakenoble's suggestions:

exec("C:\wamp\bin\php\phpVERSION_NUMBER\php.exe -f C:\wamp\www\path\to\backgroundProcess.php");

回答1:


You can use exec() and add an & to the end of the call, plus an output stream:

In trigger.php

exec("php backgroundProcess.php > /dev/null &");

You can find out more here http://php.net/manual/en/function.exec.php



来源:https://stackoverflow.com/questions/5361644/use-php-to-trigger-another-php-script-then-ignore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!