Is there a scheduler (cron like) module to fire off jobs?

rsilbert - July 15, 2009 - 03:18

Hello,

I want to start off by saying that I'm new to drupal and web programming in general. I have drupal 6 installed on a linux machine and I'm looking to implement a very basic service...

I would like to run a module (or the like) on a particular timing interval, say once an hour. Once the timer expires, I want to run a job/module that will ping a web server for some data and store the data on my drupal site. An example could be that once an hour, my module is invoked and grabs stock quotes for a list of stocks and stores them in my drupal database.

1. Does there exist a module that can run job(s) on a schedule?
2. Is there a module that pulls data from a generic web server?

Thanks in advance for your help!

To add a scheduled job inside

khorpyakov - July 15, 2009 - 04:22

To add a scheduled job inside a custom module use hook_cron() hook. Define my_module_name_cron() function with code to retrieve and update stock quotes.

There is Supercron module that extends standard cron with advanced cron hooks managment (enable/disable particular task etc).

Hi Khorpyakov, Thank you for

rsilbert - July 16, 2009 - 03:14

Hi Khorpyakov,

Thank you for your reply. Is hook_cron() called at the same time cron.php is called? Can I configure my custom task to run more frequently?

Thank you.

hook_cron() is indeed called

Jay Matwichuk - July 16, 2009 - 06:04

hook_cron() is indeed called when cronjobs are run. You can set up cronjobs to run as often as you want, but it is a server setting, not a Drupal setting.

If you want a purely Drupal solution, you can use the poormanscron module. This acts like a cronjob, though there is a slight difference - it doesn't run automatically exactly at the time you want, rather, it runs on the first page access (by anyone) after the time that you set it to run. So if you want your cronjob to run on the hour (i.e. at :00 minutes every hour), it will run on the first page access after that. So if no one accesses your site between say 11:59 and 12:15, it will not run until 12:15.

So if you need precise timing, a cronjob is the way to go. But if you need mostly accurate timing, poormanscron is a good solution.

Do you have any experience

rsilbert - July 17, 2009 - 04:38

Do you have any experience with SuperCron or Elysia Cron? These seem to act like Poormans Cron as you described. Would you recommend one over the other?

Thanks.

Poormanscron launches cron

gotheric - July 19, 2009 - 17:42

Poormanscron launches cron when users access your site... if you have a site with a LOT of traffic this could be used like you need .... but if you don't and you have a fine-grained crontab forget about it.

Poormancron is useful when you can't access a crontab... if you have a linux server this is not your case.

With elysia_cron you can have crontab-like scheduling configuration of each job.

From the topic:
what is difference between elysia cron and super cron?

.........

With this you can configure each job to run with his own timing.
For example you can configure a job to run every 2 hours, another to run every monday and another one to run at 2:13am of the 1st day of the month.
The configuration follow unix-crontab syntax, so if you're familiar with unix configuration it should be very easy for you to configure your system.

This i the main feature of Elysia Cron and the one that makes Elysia cron unique.

Another important feature is the api methods that developer could use to define multiple cron handler for their modules, and their default timings.
So for a module developer it's easy to define a job to run weekly and another every hour.
(You can find a similar feature in the CronPlus module).

.........

For the list of differences see the rest of the message:
what is difference between elysia cron and super cron?

Thanks for your help. I'll

rsilbert - July 20, 2009 - 05:16

Thanks for your help. I'll have to play around with both to get a feel for which I prefer.

 
 

Drupal is a registered trademark of Dries Buytaert.