SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Cron job problems with Carp
-
May 21, 2009, 03:08 #1
- Join Date
- May 2008
- Posts
- 70
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Cron job problems with Carp
Hi,
I have been using the CaRP RSS to html converter and for this I implemented over 50 cron jobs (one for each news category on a website) to keep things speedy.
Recently they were all cut off due to them being a big drain on server resources. The solution to this I was told, is to use a script similar to this (which I have named "update.php":
Code:<?php # Create the associative array as LongName => ShortName # Add as many as needed. Be sure to use a comma at the end. $celebs = array( 'GeorgeClooney' => 'clooney', 'CherylCole' => 'cole', 'Couples' => 'couples', 'Actors' => 'actors', ); # Loop through every item in the array and perform some action. foreach ( $celebs as $lname => $sname ) { echo "Do something for long name $lname or for short name $sname\n"; } ?> <?php # Create the associative array as LongName => ShortName # Add as many as needed. Be sure to use a comma at the end. $celebs = array( 'GeorgeClooney' => 'clooney', 'CherylCole' => 'cole', 'Couples' => 'couples', 'Actors' => 'actors', ); # Loop through every item in the array and perform some action. foreach ( $celebs as $lname => $sname ) { echo "Do something for long name $lname or for short name $sname\n"; } ?>
So, for example, I have the update_actors.php script, as follows:
Code:<?php require_once '/usr/local/apache/celebsusa/carp/carp/carp.php'; /* set the cache interval to 1 minute (you'll control how often the cache is actually refreshed with your cron settings, not here) */ CarpConf('cacheinterval',1); CarpCache('http://feeds.feedburner.com/actorsc','actors'); ?> <?php require_once '/usr/local/apache/celebsusa/carp/carp/carp.php'; /* set the cache interval to 1 minute (you'll control how often the cache is actually refreshed with your cron settings, not here) */ CarpConf('cacheinterval',1); CarpCache('http://feeds.feedburner.com/actorsc','actors'); ?>
Therefore, there is obviously something missing here and it must be the CarpCache and CarpConf parts of the update script.
Does anyone have any idea how I can get this working?
Thanks,
Dan
ps. I have posted on the Carp forums and also the Daniweb forums but with no luck as of yet unfortunately.
-
May 21, 2009, 04:58 #2
It sounds to me like you are not caching your data but building everything from RSS as required. This is a bad idea. Not many RSS files update more than twice a day anyhow some no more than once a week.
Better to have your 50 carp commands (as you had in cronjobs) in a file with a time variable, execute one each time your main page is loaded (providing the timer is timed out) and set the timers for 30 min intervals. Then when you have the carp data write it to a file and when you display always go to this file to display and not straight to carp.
This should even out server loading.
-
May 21, 2009, 06:16 #3
- Join Date
- May 2008
- Posts
- 70
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Mattinblack,
Thanks for the reply. There is one snag here: I don't have a clue how to do what you just to told me. I would rather modify what I am working with already as I at least think I have a slight grasp on how it works.
Also, most of the rss feeds are from quite active sites so are updated frequently.
Cheers,
Dan
-
May 22, 2009, 14:23 #4
-
May 28, 2009, 03:05 #5
- Join Date
- May 2008
- Posts
- 70
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
OK, I still have had no luck sorting this out. Does anybody have a solution to this? Any help massively appreciated.
Cheers,
Dan
Bookmarks