定时任务

  1. <?php
  2. use Hyperf\Contract\StdoutLoggerInterface;
  3. use Hyperf\Nano\Factory\AppFactory;
  4. require_once __DIR__ . '/vendor/autoload.php';
  5. $app = AppFactory::create();
  6. $app->addCrontab('* * * * * *', function(){
  7. $this->get(StdoutLoggerInterface::class)->info('execute every second!');
  8. });
  9. $app->run();