Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Scheduled task not executing

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: 703 Views
  • jpmcc
    Avatar
    Community Member
    14 Posts

    Scheduled task not executing Link to this post

    Hello.

    I have a daily scheduled task successfully running on the site I am working on, which is great. However, I need to implement another scheduled task at a different frequency, so I created a task subclassing the QuarterHourlyTask and set the cron to run every 15 minutes. I implemented it exactly the same way as the daily task except for the different parent.

    However, if I execute on the command line:

    /path/to/php /path/to/webroot/sapphire/cli-script.php QuarterHourlyTask

    Only

    QuarterHourlyTask

    is echoed implying that my subclass was not found. I've rebuilt the manifest.

    Looking at CliController, it takes the class specified, finds all the subclasses and loops through them, echoing out the classname as it goes. Works fine for DailyTask. If, via a browser, I create a test function to list out the subclasses of QuarterHourlyTask, my task is listed, however when running from the command line, it isn't found.

    Works fine on my local environment.

    Anyone had this sort of thing and sorted it? It is probably something simple, but at the minute I just can see it.

    Thanks,
    Jason.

  • jpmcc
    Avatar
    Community Member
    14 Posts

    Re: Scheduled task not executing Link to this post

    Just a further observation.

    I have added some new functionality to the site that is all functioning well when viewed via the admin interface and the front end. However, in my daily task that was executed this morning (this is the task that works), a fatal error was thrown that one of the new classes that I have added (and is working), was not found.

    I do recall that when I previously added a report, although working nicely in the admin, the next daily task run complained that it didn't exist, (or rather that it wasn't a child of SS_Report). I assume the project _config.php was being parsed and that is where the report was being registered with the ReportAdmin. My new class, that is the focus of the current error, is also referenced in the project _config.php where the DataObjectManager SortableDataObject is used.

    This leads me to believe there is some difference in the manifest information that the CliController uses and the standard website, that seems to even out over some time, as the previously mentioned Report error just disappeared.

    Can anyone shed any light?

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Scheduled task not executing Link to this post

    Tried passing a flush=1 to the script via cli? There are seperate manifest files for cli and_www,

    /path/to/php /path/to/webroot/sapphire/cli-script.php QuarterHourlyTask "?flush=1"

  • jpmcc
    Avatar
    Community Member
    14 Posts

    Re: Scheduled task not executing Link to this post

    Thanks.

    I'd just this second found that out and tried flush=all and bingo, then logged in here to add my findings, but you got there first!

    At first I hadn't noticed in the silverstripe-cache directory the two files "manifest-main" and "manifest-cli-script", which obviously would explain what I'd been seeing. Then a quick revisit to the commandline docs and seeing that $_GET params can be passed in as you describe, I thought I'd give flush a go. Sorted.

    Just for completeness:

    /path/to/php /path/to/webroot/sapphire/cli-script.php QuarterHourlyTask flush=all

    The only question remains is how the manifest was previously built and the report error that I had noticed seemed to disappear by itself, as I didn't carry out a flush then, yet the DailyTask had been running for a while. That answer is only required out of interest now I know that I need to carry out a manifest rebuild for cli as well as www when I add new stuff that impacts on _config.php

    703 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.