thhan / schedule-bundle
thhan ScheduleBundle
1.0.0
2020-02-24 18:47 UTC
Requires
- php: ^7.1.3
- mtdowling/cron-expression: ^1.2.3
This package is auto-updated.
Last update: 2024-09-25 05:01:39 UTC
README
此包提供了一种通过简单函数将控制台命令添加到cron作业的功能。
安装
composer req thhan/schedule-bundle
手动注册此包。
// config/bundles.php return [ // Other bundles... Thhan\ScheduleBundle\ScheduleBundle::class => ['all' => true], ];
服务器配置
最后,您在服务器上创建一个cron作业,每分钟执行“schedule:run”命令。
* * * * * {path_to_symfony}/bin/console schedule:run >> /dev/null 2>&1
用法
将Trait Schedule类添加到您的控制台命令中。通过“addCron”函数扩展配置函数。作为参数,您传递一个字符串或字符串数组,格式为cron作业。
use Thhan\ScheduleBundle\Command\Schedule; class YourCommand extends Command { use Schedule; public function configure() { $this->setName('app:test') ->addCron('30 3 * * *') ->addCron([ '*/10 * * * *', '0 22 * * 1' ]); } }
计划
- 通过配置添加作业
- 添加输出日志器