Non stop reload of a page to server

November 5, 2009 at 23:58:27
Specs: Windows XP, 700mb
I need to reload a php page to a server again and again continuously 24/7. I am running locallhost. I cant use timed reload like <META HTTP-EQUIV="Refresh" content="5;url=http://localhost/php_reloader.php> as this will introduce synchronization problems. I need to reload when the code executes to the end.

The following is what I have done but it stops after about 20minute. I think it runs out of memory. On the page reload1.php I have put the code:

//I have put my php code in this area. normal code that is working ok
bla...bla...bla in php!

//Now at the end of my bla.. bla... code I call (by include) the other page called //reload2.php like so;
include ("reload2.php"); //this includes relaod2.php

//Now my trick is I have the same bla.bla.bla code on reload2.php and make it call relaod1.php as follows:

//I have put my php code in this area. normal that is code working ok
bla...bla...bla in php!

//Now at the end of my bla.. bla... code i call (by include) the other page called reload2.php
include ("reload1.php"); //this includes relaod1.php

By doing this I hope to create an indefinite cycle of reload1.php calling reload2.php and then reload2.php calling back reload1.php. Perpetual machine? Yes!!! At the first it was working just for a few seconds. I realized I needed to change "resource limits" on the php configuration file (php.conf). I changed to below

max_execution_time = -1 ; Maximum execution time of each script, in seconds(30)
max_input_time = -1 ; Maximum amount of time each script may spend parsing ;request data(60)
memory_limit = -1 ; Maximum amount of memory a script may consume (16MB)

I changed the parameters above to -1 to make them limitless.(otherwise the default are the values show in brackets). This improved my perpetual machine to run from seconds to over fifteen minutes. But I don't want it to stop at all (unless i say so).

Windows Task Manager shows that PF (memory) usage fills up slowly until it matches that of the available RAM, and then the whole thing stops. This happens even when an I have put nothing in the code to echo to the browser.

Please help!

See More: Non stop reload of a page to server

Report •

November 6, 2009 at 00:35:46
Well, that is going to do exactly that - include itself forever until it eats up all your RAM.

The refresh must be done CLIENT side - you can't do it server-side with php. The best you could hope for is:


But all that does, is nicely ask the browser to refresh to the given URL in 2 seconds - there's no guarantee that it will ever happen.

Other methods are the meta tag refresh you described, and a javascript refresh, but there's always going to be latency, the web server will delay the request if it's really busy - nothing you can do about it. HTTP is the wrong protocol for low latency communications.

Report •

November 6, 2009 at 04:34:24
Walaa! I got my perpetual machine running!! Thank you Fist for reminding me about Javascript.

All I needed was to call a Javascript function from my php like so...


echo "<SCRIPT LANGUAGE='javascript'>reloader();</SCRIPT>";


And my javascript function being

<script type="text/javascript">
function reloader() {


Of course my reloader() is still timed but I can call it from any part of my php block. That's what I wanted. I have run it none stop for more than an hour now and my memory is intact. Yes there is some latency but that's fine with me as I need to this to read a GPRS modem. Currently I can change the function timing to be able to read three cycles in a second. That's way too fast for my modem. (though my earlier solution could do 30Hz)


Report •

November 7, 2009 at 21:36:17
ya........javascrip is the best solution for this.I used the same technique in one of our client project in
The above description is perfect soln for this.

Report •

Related Solutions

March 15, 2010 at 16:27:22
There must be a problem in the internal settings of the server which needs to be monitored

underwater plants | plants of the desert

Report •

May 17, 2010 at 09:31:56
Thanks, i got the hint from this conversation.

Axis Technolabs, CA, USA
Website Design

Report •

Ask Question