Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addCrontab 定时任务没有运行 #68

Open
zhenggg opened this issue Dec 1, 2023 · 1 comment
Open

addCrontab 定时任务没有运行 #68

zhenggg opened this issue Dec 1, 2023 · 1 comment

Comments

@zhenggg
Copy link

zhenggg commented Dec 1, 2023

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);
});

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

@teg1c
Copy link

teg1c commented Jan 5, 2024

记得安装 hyperf/process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants