开发者

Executing PHP Scripts from another PHP Page but allowing Parent page to continue executing

I'm trying to find an answer that doesn't seem to be covered on similar threads I've found here.

I have a page that takes a url from the user. I want to the execute five different scripts that will each access 3rd party sites to establish details on this URL, perform calculations and write the results to a database. Each script is a separate php file.

I've so far gathered that the way to do this would be through the exec command but I have two problems with this

1) I don't want the page's output (there isn't any - results go into the 开发者_如何学GoDB) 2) I want the scripts to run 'in the background' almost like a daemon or cron job, and for the page to load telling the user the details are retrieved and will be available shortly.

Does anyone have a code example of how I would launch the scripts, but not have to wait for them to finish executing before loading the page that the user sees?


Have you tried something like this?

exec('php -f script.php > /dev/null &');

The process will be ran in background and you don't have to wait for it to finish to execute another commands.


You want something like gearman.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜