I wasn’t sure how to title this thread, sorry.
I have a script that processes some logs and I echo a lot of debug information as the process goes. Since moving to the new server, it seems that the script hangs for 30 odd seconds, then spits out all the logging, then hangs again for 30 odd seconds and the process continues.
This is really odd behavior and I don’t know where to start. Its like it isn’t processing the file line by line but in blocks …
PHP version is 5.1.6 on a CentOS running plesk. (My old CP was CPanel)
Any ideas?
EDIT: Simple example of my issue – Running this code:
for ($i=0; $i<100; $i++) {
echo "test $i";
sleep(1);
}
the script will hang for 100 seconds, then print out all the “test 1” ect. Sleep is required in my main script and on the other server just echoed the values in turn.
EDIT2: Have tried setting output_buffering = 0 and implicit_flush = On and didn’t help.
You may have
output_bufferingOn. Try to disable it first.You can do it either in the php.ini file, in a .htaccess file if your server allows it, or use the following code at the beginning of your PHP script:
Also, use
flush()after eachechoorprint, and it should be all right!Update:
You might also encounter other buffers that you cannot control from within PHP (web server, browser, …), which is why you’re still not seing anything. A workaround is to send some blank bytes after each print:
However, while this example works for me on IE & Firefox, it does not work on Chrome!