gumphp/think-crontab

workerman/crontab for thinkphp

v1.0.2 2023-06-15 03:39 UTC

This package is auto-updated.

Last update: 2024-12-15 07:00:25 UTC


README

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