homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Run PHP to generate a file on the server side

5+ Year Member

Msg#: 4399236 posted 3:31 am on Dec 19, 2011 (gmt 0)

Hi All,

I operate a Wordpress web site, and my experience with PHP is limited to modifying Wordpress templates to achieve the HTML output I'm looking for.

I have a situation where my wordpress template is calling Yahoo Pipes to get a PHP array based on RSS aggregation to display on a page. Problem is, it takes about 7 seconds to load the page.

If I do this synchronously with the page load (which is all I've ever done), it seriously delays the page load.

What I would like to do is separate out the PHP call to Yahoo Pipes into another process - basically run it every 15 minutes or so, and generate an output file on my server. Then, I could include that output file in my PHP load of the home page for my site.

Does that make sense? Seems to me I should be able to do this using cron or something like that, but I've never run any PHP except via my wordpress install.




WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4399236 posted 5:01 pm on Dec 19, 2011 (gmt 0)

Yes, a cron is what you want, but I wouldn't run it every 15 minutes if it's taking 7 seconds to load. This (usually) means it's using a fairly intense amount of system resources, and knowing the way many PHP scripts are written, probably storing a lot of data in memory. If you're in a shared environment, your host might yell at you. :-)

Anyway you just create the script to do what you want - these days the easiest way to create the cron is go into your hosting management control panel to create the cron job itself. You would set the time values, then use the full system path to the script - not the url/uri:

php /home/var/www/example.com/mycron.php

You might have to specify the full path to php,

/usr/bin/php /home/var/www/example.com/mycron.php

Your system paths will be different, but that's the gist. Your CP will have help files on how to set the time values. Make sure cron logging is enabled, this will give you good info if the script errors or you have a bad path.

Experiment with a small script that does something like write to a file or email you to test it before jumping in to the live script.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved