Redirect output to a file on the web server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings List members,

I have a script that takes quite a while to run, one or two hours, I wish to
redirect the normal php output to a file on the webserver itself. I don't
mind if in the process, the browser displays a blank page. The reason I want
to do this is that if the script crashes or the browser Is closed by
mistake, I have absolutely no record of where the script stopped running.

I could use code like below
At the beginning of the script:
ob_start();

At the end of the script:
$page = ob_get_contents();
ob_end_flush();
$fp = fopen("output.html","w");
fwrite($fp,$page);
fclose($fp);

However, I see some problems with this:
I'm not too sure of the size of the output. It may balloon to over the
buffering limit (in PHP? Apache?) and then what happens?
Secondly, if the script crashes before the end, I won't get any output.
Finally, I am using a library in the script that outputs status and error
messages of its own. So, if I manually opened a file and used fwrite()
alongside echo for my messages, I would lose out on those messages.

Anybody has any pointers on how you could send the output not only to a
browser, but also to a file on the webserver? If not, at least to a file?

Thanks and regards,
Ferdi

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux