PHP command to run a script and save resulting code
Posted: Tue Nov 02, 2010 7:23 pm
Hi there
Currently I have a script which runs every hour via cron. The command I'm using is "php /var/www/html/news.php > /var/www/html/index.html".
I have a couple of issues with this:
1) It seems to add the line "Content-type: text/html" to the very top of the HTML file when it's generated.
2) The script reads quite a lot of data and takes about 3 minutes to run. The page is built gradually and looks broken for 3 minutes of every hour, until the script has finished and the page is fully built.
What I'd like to do is replace this cron command and execute a php file that perhaps does the following:
1) executes the script
2) saves it to a file index-temp.html
3) waits 3 minutes until the file has fully finished
4) overwrites the previous index.html with the new one.
Can anyone suggest what the best practice would be, and what code I might use to do it?
Thanks in advance for your help.
Currently I have a script which runs every hour via cron. The command I'm using is "php /var/www/html/news.php > /var/www/html/index.html".
I have a couple of issues with this:
1) It seems to add the line "Content-type: text/html" to the very top of the HTML file when it's generated.
2) The script reads quite a lot of data and takes about 3 minutes to run. The page is built gradually and looks broken for 3 minutes of every hour, until the script has finished and the page is fully built.
What I'd like to do is replace this cron command and execute a php file that perhaps does the following:
1) executes the script
2) saves it to a file index-temp.html
3) waits 3 minutes until the file has fully finished
4) overwrites the previous index.html with the new one.
Can anyone suggest what the best practice would be, and what code I might use to do it?
Thanks in advance for your help.