Hi all,
I'm developing a site with Drupal that has a stock index "quoter" on the front page. I've successfully installed the stockapi module to store information from Yahoo Finance and I'm making my own module to display that information.
Right now, I haven't got a cron job setup on my server to run in scheduled intervals. I would like to have the stock prices update every 15 minutes (or possibly more often), but I don't want the site to run a full cron job every 15 minutes. I've been unable to find any sort of documentation on this, but is it possible to just run the cron for the stockapi module and not the whole site? If so, where do I begin?
I guess to preface the above question I must ask if it is even an issue to run a full cron job 4 times or more per hour. From what I've read in the documentation it seems that once per hour is the norm.
Any thoughts or suggestions would be greatly appreciated.
Thanks,
Damien
Comments
=-=
I run a full cron job every 15 mins on sites as a norm. this runs the search index and such, so I wouldn't want anything left out of search for much longer.
create your own cron.php
I've had to deal with a similar situation before. In order to get around it, I created an additional cron script that executed /only/ the function I wanted run frequently.
First, change the name of the function in your module from modulename_cron() to modulename_custom_cron() or something like that so it doesn't get executed when the normal cron runs. In the same directory where cron.php exists (the root directory of your Drupal installation), create a new script (mine is called mls_cron.php [mls is the name of my module]). Copy/paste the contents of cron.php into the new file. Replace the line 'drupal_cron_run();' with 'modulename_custom_cron();'. Then, create a cronjob that calls your new script every 15 minutes.
Thanks for the help. It is
Thanks for the help. It is working great!
No need to hack the module
Thank you for your suggestion. I am a bit hesitant to modify the module functions to get this result since you need to keep track of the changes you have made and redo them after updates.
I followed your suggestion and created a new cron file in addition to the default one, named twitter_cron.php which contains the following:
<?php
// $Id: cron.php,v 1.36 2006/08/09 07:42:55 dries Exp $
/**
* @file
* Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
*/
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
twitter_cron();
this directly runs the twitter function instead of running all modules functions. This way I can have the twitter module updated every 5 minutes and the rest of the modules every hour.
or use drush
drush --uri=http://www.yoursite.com/ php-eval ' yourmodule_cron(); ';