承接 sharkom/yii2-cron 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sharkom/yii2-cron

最新稳定版本:v2.0.1

Composer 安装命令:

composer require sharkom/yii2-cron

包简介

Create Cron jobs from browser, and look that run logs

README 文档

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

ChangeLog 27/Feb/2023

  1. Add Manual Run button on cronjob page
  2. Add auto purge logs (use module param purge_log_interval | default 3 months)
  3. Fix some graphics in logs pages

ChangeLog 5/May/2023

  1. Added execution error mail notifications
  2. Added auto unlock mail notifications
  3. Added module param sendNotifications

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',
        'params'=>[
            'sendNotifications'=>true,
        ]
    ],
],

Console Application Config

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

Simple example:

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

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

###Email notifications

In order to recieve email notifications for execution errors you need to config:

  1. The module param sendNotifications to true (check Web App and Console App configuration in this readme)
  2. Set in common/config/params.php the parameters:
    1. senderEmail
    2. NotificationsEmail
  3. Configure the mailer in common/config/main-local.php
return [
    'senderEmail'=>'notifications@yourapp.net',
    'NotificationsEmail'=>'notifications@yourapp.net',
];
'mailer' => [
   'class' => 'yii\swiftmailer\Mailer',
   // send all mails to a file by default. You have to set
   // 'useFileTransport' to false and configure a transport
   // for the mailer to send real emails.
   'useFileTransport' => false,
   'transport' => [
      'class' => 'Swift_SmtpTransport',
      'encryption' => 'tls',
      'host' => 'your smtp relay',
      'port' => '25',
      'username' => 'your user',
      'password' => 'your password',
   ],
],

.

统计信息

  • 总下载量: 4.76k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-11