Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

ScheduledTask not working ... noob help please!


Reply

5 Posts   375 Views

Avatar
nimesodelta

9 November 2011 at 7:55pm Community Member, 18 Posts

Hi All,

I've been racking the forums for 2 hours now and only seem to be moving forward slowly...

I've extended QuarterHourlyTask as follows:

<?php
class ZQQuarterHourlyTask extends QuarterHourlyTask {
   
   public function process(){
      $From = "test@gmail.com";
      $To = "test@gmail.com";    
      $email = new Email($From, $To, "TEST TASK", "TEST TASK");
      $email->send();
      
      Debug::message("Yes it works! Yippie!");
   }
   
}

this seems to work fine if I go to http://mysite/ZQQuarterHourlyTask and the email gets sent a-ok and I can see the debug message.

Problem is... as of yet it doesn't send the email automatically every fifteen minutes it ONLY works when I test it through the URL?

Am I missing somthing here?

Any help would be great! I'm tearing my hair out.
I'm running wamp on a pc if that helps

Thanks heaps!

Jamie

Avatar
nimesodelta

10 November 2011 at 11:42am Community Member, 18 Posts

Anyone? please help. :) was up till 4am trying to solve this one and had nightmares about code... lol

Cheers
Jamie

Avatar
JonoM

10 November 2011 at 12:56pm Community Member, 103 Posts

Hi Jamie,

I wasn't aware of this function before but if you look at the API docs http://api.silverstripe.org/trunk/sapphire/cron/ScheduledTask.html you can see that it's not enough to subclass a ScheduledTask - you still have to trigger the tasks by using something like cron. There's a sample cron setup on that page but I'm not sure how you would set up same on WAMP.

Avatar
nimesodelta

11 November 2011 at 11:29pm Community Member, 18 Posts

Thanks Jono!

So I'm kinda safe to say that if testing through the browser works fine then I dont need to worry untill the site is on the live server? then I'll hassle the hosting guys to help me out? lol :)

If it works in the url test then it should be fine once the server guys create a cron job etc etc...

Can I de-stress a bit now?

Cheers
Jamie

Avatar
JonoM

12 November 2011 at 12:54pm Community Member, 103 Posts

I think so :) cron jobs aren't hard to set up in something like cpanel so if it works through the URL then I think you should be good