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