Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 667 Bytes

README.md

File metadata and controls

40 lines (32 loc) · 667 Bytes

安装

composer require gumphp/think-crontab

使用

<?php
namespace app\crontab;

use gumphp\crontab\Crontab;

class Test extends Crontab
{
    // 每秒执行一次
    protected $rule = '* * * * * *';
    
    public function handle()
    {
        $message = __METHOD__ . "\t" . date('Y-m-d H:i:s') . PHP_EOL;
        error_log($message, 3, runtime_path() . 'debug.log');
    }
}

Test 加入 config/crontab.phphandlers 配置

<?php
return [
    # ...
    'handlers' => [
        \app\crontab\Test::class,
    ],
];

启动守护进程

php think crontab start