Table of Contents

Recurring jobs on SilverStripe Platform are managed in one of two ways - the CronTask module, or as a server-defined cronjob. The key difference is that by default, a cronjob will run on every server in the environment. If you are utilising Virtual Stacks, a cronjob will affect all of them, as they are hosted on the same infrastructure. This may or may not be desired, depending on the job, but will most likely cause unexpected conflicts. Usually, your best bet is to use a crontask.

Using a CronTask

As part of using SilverStripe Platform, you should already have the silverstripe/crontask module installed. When the crontask runs, it will utilise sera in order to ensure that only one server will run the task at any one time, regardless of how many servers are in-use on the current environment. This is important to note if you are migrating from a non-distributed system, as this is probably the expected outcome of the running task.

By way of example, Solr search on SilverStripe Platform requires the QueuedJobs module to run the reindex and commit tasks. Usually, you would simply set up (something like) the following cron on the server:

* * * * *   www-data    /var/www/mysite/framework/sake dev/tasks/ProcessJobQueueTask | logger -t QueuedJobs_cron

However, this would run on each server on the distributed infrastructure of SSP, potentially resulting in the same task being executed multiple times simultaneously. The recommended way to run this is the following CronTask:

class QueuedJobsCron implements CronTask {

    public function getSchedule() {
        return "* * * * *";

    public function process() {
        $task = new ProcessJobQueueTask()
        //run() takes an argument of the current request, use null if there is no expected request data to pass in.

This ensures that the task only runs once across the entire environment.

Using a CronJob

Starting with SilverStripe Platform version 3.3.0, you are able to define cronjobs in your .platform.yml file like so:

    time: "0 20 * * *"
    sake_all: "dev/tasks/MyTask"
    vhost: "mysite"
    time: "1 21 * * *"
    sake_once: "dev/tasks/MySecondTask"
    vhost: "mysite"

In the example above, the first task will be run once a day, and on each server in the environment. In some cases this may be one server; in others, up to 16. Make sure you take this into consideration when adding a cronjob to your .platform.yml file, as running the same task from multiple boxes at the same time can cause race conditions and other issues.

The second task will also be run once a day, but only on at most one server. The cron always runs as the web user www-data. You can read more about cronjobs in the .platform.yml documentation

Please note that this is a more advanced option for configuration - if you have any questions at all, please don’t hesitate to contact the support team.