123456789101112131415161718192021222324252627 |
- <?php
- declare(strict_types=1);
- namespace App\Task;
- use App\Master\Framework\Extend\BaseTask;
- use App\Utils\LogUtil;
- use Hyperf\Crontab\Annotation\Crontab;
- #[Crontab(rule: "*/5 * * * * *", name: "DemoTask", callback: "execute", memo: "定时任务示例 每5秒执行一次", enable: false)]
- class DemoTask extends BaseTask {
- //日志板块
- protected string $LOG_MODULE = 'DemoTask';
- public function __construct()
- {
- parent::__construct();
- }
- public function do(): bool
- {
- // 打印当前毫秒级时间戳
- LogUtil::info('do', $this->LOG_MODULE, __FUNCTION__, time_ms());
- return $this->success('执行成功');
- }
- }
|