October CMS resources and help articles

Simple and to the point. Optimized by the community.

Defer the execution of artisan commands on the queue

4
by alxy, last modified on August 12th, 2019

Sometimes you may wish to defer the execution of some custom artisan command. Here is how you do it in October:

use Carbon\Carbon;
use Illuminate\Foundation\Console\QueuedCommand;

QueuedCommand::dispatch(['mycommand:do-something', ['argument' => $value]])->delay(Carbon::now()->addMinutes(30));

Like this, the command will be pushed on the queue and the execution will start after 30 minutes. Don't forget to set up your queue workers!

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?