adcalls/yii2-cron

Yii2 cron extension

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2020-05-12 14:22 UTC

This package is auto-updated.

Last update: 2024-04-14 18:16:40 UTC


README

An extension for running cron tasks via PHP.

Basic usage

Tasks are stored in a config array in a file. The default file is `@app/config/tasks.php`, but this can be overwritten by the `tasksFile` property. The `tasksFile` should contain an array of task config arrays.

The tasksFile should look similar like below:

<?php
return [
    'app\tasks\EchoTask', // Run every minute
    [
        'class' => 'app\tasks\WeeklyTask',
        'daysOfWeek' => [Carbon::MONDAY],
        'hours'      => [8],
        'minutes'    => [15],
    ], // Run every monday at 08:15
];

The supported properties for when to execute are listed below. Use the constants from Carbon for the "days" and "daysOfWeek" properties.

  • years
  • months
  • weeks
  • days
  • daysOfWeek
  • hours
  • minutes