sharkom/yii2-cron

Create Cron jobs from browser, and look that run logs

Maintainers

Details

github.com/SharKom/yii2-cron

Source

Installs: 24

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 5

Type:yii2-extension

1.1.4 2021-10-21 08:02 UTC

This package is auto-updated.

Last update: 2021-11-21 08:08:37 UTC


README

Create Cron jobs from browser, and look that run logs

Forked from vasadibt/yii2-cron with some modifications:

  1. Now it can run every kind of script, not only Yii2 console commands
  2. Added capability to have a log file in addition to DB logs
  3. Removed the runquick capabilities

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist sharkom/yii2-cron "*"

or add

"sharkom/yii2-cron": "*"

to the require section of your composer.json file.

Migration

Run the following command in Terminal for database migration:

yii migrate/up --migrationPath=@sharkom/cron/migrations

Or use the namespaced migration (requires at least Yii 2.0.10):

// Add namespace to console config:
'controllerMap' => [
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationPath' => [
            '@sharkom/cron/migrations',
        ],
    ],
],

Then run:

yii migrate/up

Web Application Config

Turning on the Cron Job Manager Module in the web application:

Simple example:

'modules' => [
    'cron' => [
        'class' => 'sharkom\cron\Module',
    ],
],

Console Application Config

Turning on the Cron Job Manager Module in the console application:

Simple example:

'modules' => [
    'cron' => [
        'class' => 'sharkom\cron\Module',
    ],
],

Schedule Config

Set the server schedule to run the following command

On Linux:

Add to the crontab with the user who you want to run the script (possibly not root) with the crontab -e command or by editing the /etc/crontab file

* * * * * <your-application-folder>/yii cron/cron/run 2>&1

On Windows:

Open the task scheduler and create a new task