PHP后台进程 [英] PHP Background Processes

查看:76
本文介绍了PHP后台进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个PHP脚本,我已经完成了脚本,但是大约要花10分钟才能完成它打算完成的过程.这不是问题,但是我想我必须一直保持页面加载,这很烦人.我可以拥有它,以便我开始该过程,然后在10分钟后回来并仅查看它生成的日志文件吗?

I'm trying to make a PHP script, I have the script finished but it takes like 10 minutes to finish the process it is designed to do. This is not a problem, however I presume I have to keep the page loaded all this time which is annoying. Can I have it so that I start the process and then come back 10mins later and just view the log file it has generated?

推荐答案

好,您可以使用"

Well, you can use "ignore_user_abort(true)"

因此脚本将继续起作用(注意脚本的持续时间,也许添加" set_time_limit (0))

So the script will continue to work (keep an eye on script duration, perhaps add "set_time_limit(0)")

但是这里有个警告:您将无法通过以下两行来停止脚本:

But a warning here: You will not be able to stop a script with these two lines:

ignore_user_abort(true); 
set_time_limit(0);

除非您可以直接访问服务器并杀死那里的进程! (在那儿,进行了无休止的循环,一次又一次地调用自己,使服务器急停下来,大喊大叫……)

Except you can directly access the server and kill the process there! (Been there, done an endless loop, calling itself over and over again, made the server come to a screeching stop, got shouted at...)

这篇关于PHP后台进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆