| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use App\Jobs\FiveSecondTaskJob;
- use Illuminate\Support\Facades\Log;
- class StartFiveSecondTask extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'five_task';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Command description';
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- $this->info('启动10秒循环任务...');
- Log::error('启动10秒循环任务...'.now());
- // 首次启动任务
- FiveSecondTaskJob::dispatch()->delay(now()->addSeconds(10));
-
- $this->info('任务已启动,将在10秒后首次执行');
-
- return Command::SUCCESS;
- }
- }
|