PHP code example of silverstripe / crontask

1. Go to this page and download the library: Download silverstripe/crontask library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

silverstripe / crontask example snippets


use SilverStripe\CronTask\Interfaces\CronTask;

class TestCron implements CronTask
{
    /**
     * run this task every 5 minutes
     *
     * @return string
     */
    public function getSchedule()
    {
        return "*/5 * * * *";
    }

    /**
     *
     * @return void
     */
    public function process()
    {
        echo 'hello';
    }
}

public function getSchedule()
{
    return "0 1 * * *";
}

public function process()
{
    $task = FilesystemSyncTask::create();
    $task->run(null);
}

[email protected]
* * * * * www-data /usr/bin/php /path/to/silverstripe/docroot/framework/cli-script.php dev/cron quiet=1