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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

ScheduledTask not working ... noob help please!


Go to End


5 Posts   774 Views

Avatar
nimesodelta

Community Member, 22 Posts

9 November 2011 at 7:55pm

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

Community Member, 22 Posts

10 November 2011 at 11:42am

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

Cheers
Jamie

Avatar
JonoM

Community Member, 130 Posts

10 November 2011 at 12:56pm

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

Community Member, 22 Posts

11 November 2011 at 11:29pm

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

Community Member, 130 Posts

12 November 2011 at 12:54pm

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