workerman/crontab

基于 workerman 的 PHP 编写的 crontab

v1.0.6 2022-10-17 01:59 UTC

This package is auto-updated.

Last update: 2024-08-29 05:40:24 UTC


README

一个基于 workerman 的 PHP 编写的 crontab,具有秒级精度。

安装

composer require workerman/crontab

用法

start.php

<?php
use Workerman\Worker;
require __DIR__ . '/../vendor/autoload.php';

use Workerman\Crontab\Crontab;
$worker = new Worker();

$worker->onWorkerStart = function () {
    // Execute the function in the first second of every minute.
    new Crontab('1 * * * * *', function(){
        echo date('Y-m-d H:i:s')."\n";
    });
};

Worker::runAll();

使用命令 php start.php start 或 php start.php start -d 运行