Jump to:

23487 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » ScheduledTask not working ... noob help please!

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

Page: 1
Go to End
Author Topic: 371 Views
  • nimesodelta
    Avatar
    Community Member
    18 Posts

    ScheduledTask not working ... noob help please! Link to this post

    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

  • nimesodelta
    Avatar
    Community Member
    18 Posts

    Re: ScheduledTask not working ... noob help please! Link to this post

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

    Cheers
    Jamie

  • JonoM
    Avatar
    Community Member
    103 Posts

    Re: ScheduledTask not working ... noob help please! Link to this post

    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.

  • nimesodelta
    Avatar
    Community Member
    18 Posts

    Re: ScheduledTask not working ... noob help please! Link to this post

    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

  • JonoM
    Avatar
    Community Member
    103 Posts

    Re: ScheduledTask not working ... noob help please! Link to this post

    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

    371 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.