CRON PHP加载时间


                    

我对PHP和CRON-Jobs有疑问。
我已经制作了一个php脚本,由于有很多命令,因此不得不加载很长时间。
因此,我制作了一些较小的脚本,因此命令更少了。
然后,我制作了一个“母版脚本”,该脚本通过Javascript执行一些POST请求。
但是您知道Cron doenst执行Javascript。 由于脚本之间的依赖性,整个脚本需要作为一个大脚本执行。 </ p>

是否可以在服务器上设置更高的加载超时之前的时间,或者这只是在浏览器之间? </ p>

或者还有其他想法可以解决这个问题吗? </ p>

谢谢</ p>
     </ div>

展开原文

原文

I have a question about PHP and CRON-Jobs. I've made a php script which some time have to load very very long, because there are many commands. Because of this I made several smaller scripts, so the commands are fewer. I made then a "master-script" which executes some POST-Request over Javascript. But as you know Cron doenst execute Javascript. And the whole script needs to execute as one big script because of the dependence between the scripts.

Is it somehow possible to set the time before a loading-timeout higher on the server or is this just from browser to browser?

Or are there any other ideas how I could solve this?

Thank you

3个回答


对于PHP cronjobs,您可以这样设置超时和内存限制:</ p>

  //确保我们有足够的时间和内存。
ini_set('memory_limit',-1);
ini_set('max_execution_time',0);
set_time_limit(0);
</ code> </ pre>
     </ div>

展开原文

原文

For PHP cronjobs, you can set the timeout and memory limit like this:

// make sure we have enough time and memory.
ini_set('memory_limit', -1);
ini_set('max_execution_time', 0);
set_time_limit(0);


我认为您的意思是这样,请下次发布一些代码。</ p>

如果您已经将脚本拆分为多个较小的脚本,并且确保它们可以在服务器上允许的 max_execution_time </ code>内运行,则无需创建一个处理页面 所有的JavaScript调用。
该页面所做的全部工作是创建一个会话,该会话“记住”应该运行哪个“较小的脚本”,运行的顺序以及当前正在/已经运行的当前脚本。 您的浏览器只是通过AJAX请求处理“当前步骤”。</ p>

所以在伪代码中,它可能看起来像这样:</ p>

 开始会话
加载下标的所有“步骤”
增加步数(保存到会话!)
做处理(下标1/2/3 / etc)...
将状态信息输出到浏览器,然后让javascript“轮询”此页面以获取下一步/状态信息。

</ code> </ pre>
     </ div>

展开原文

原文

I think you mean something like this, please post some of your code next time.

If you already have split up your script into multiple smaller ones, and you make sure that they can run within the max_execution_time allowed on your server, than you'll have to create a page that handles all javascript calls. All this page does is creating a session that 'remembers' which 'smaller scripts' should run, in which order and what current script is running/has run. Your browser just requests through AJAX to process 'the current step'.

So in pseudo code it could look like this:

Start session
Load all 'steps' of subscripts
Increment step number (save to session!)
Do processing (subscript 1/2/3/etc) ...
Output status info to browser and let javascript 'poll' this page for next step/status info.


谢谢大家的回答。 </ p>

我刚刚找到了另一种方法:</ p>

我使用$ _GET变量进行了切换。 因此,现在每个“子脚本”都处于一种切换状态,最后,它将$ _GET更改为下一步。 </ p>
     </ div>

展开原文

原文

thank you all for the answers.

I just found another method:

I made a switch with an $_GET variable. So now every "Sub-Script" is now in one case of the switch and at the end it changes the $_GET to the next step.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐