cyub / laravel-task-scheduler
一个轻量级的 Laravel 任务调度包
0.1.0
2017-06-30 07:05 UTC
Requires
- php: >=5.4.0
- illuminate/cache: ~5.0
- illuminate/console: ~5.0
- illuminate/support: ~5.0
This package is not auto-updated.
Last update: 2024-09-23 06:11:32 UTC
README
这是一个为 Laravel 5 设计的轻量级任务调度包。此包允许您调度所有计划的任务并在指定时间运行。
安装
需要此包
composer require "cyub/laravel-task-scheduler"
添加包后,将 ServiceProvider 添加到 config/app.php
文件中的 providers 数组中
'providers' => [ ... Tink\Scheduler\SchedulerServiceProvider::class, ... ];
然后,发布调度器配置并迁移调度器数据库
php artisan scheduler:install
配置
安装包后,您将在 config\scheduler.php
中找到配置
return [ 'enable' => true, 'schedule_table_name' => 'cron_schedule', 'schedule_generate_every' => 1, 'schedule_ahead_for' => 50, 'schedule_lifetime' => 15, 'history_cleanup_every' => 10, 'history_success_lifetime' => 600, 'history_failure_lifetime' => 600, 'schedules' => [ 'RegisterRedpacket.activate' => [ 'schedule' => [ 'cron_expr' => '*/1 * * * *', ], 'run' => [ 'class' => App\Cron\RegisterRedpacket::class, 'function' => 'activate', 'params' => ['isSendSmsNotice' => true] ], 'description' => 'activate register redpacket' ] ] ];
使用方法
调度任务并运行
php artisan scheduler:dispatch
您可以使用 Cron
* * * * * php /your-application-path/artisan scheduler:dispatch >> /dev/null 2>&1
查看调度器配置
php artisan scheduler:info config
查看调度器运行结果统计
php artisan scheduler:info stats
清理调度器缓存
php artisan scheduler:clean