Skip to content

addCrontab 定时任务没有运行 #68

@zhenggg

Description

@zhenggg
use Hyperf\Nano\Factory\AppFactory;
require_once __DIR__ . '/vendor/autoload.php';

$app = AppFactory::createSwow();

$app->config([
    'processes'=> [ Hyperf\Crontab\Process\CrontabDispatcherProcess::class,],
    'crontab' => [
        'enable' => true,
    ],
]);

$app->addCrontab('* * * * * *', function(){
    echo "A new Crontab called echo!";
    $file = 'log.txt';
    // 向文件追加写入内容
    // 使用 FILE_APPEND 标记,可以在文件末尾追加内容
    file_put_contents($file, time(), FILE_APPEND | LOCK_EX);
});

定时回调里面的代码没有执行

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions