Answer the question
In order to leave comments, you need to log in
Why does `Task Scheduling` only fire once?
app\Console\Kernel.php :
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected $commands = [
\App\Console\Commands\Inspire::class,
\App\Console\Commands\RemoveUser::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
$schedule->command('remove:user')
->everyMinute();
}
}
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
class RemoveUser extends Command
{
protected $signature = 'remove:user';
protected $description = 'Command description';
public function __construct()
{
parent::__construct();
}
public function handle()
{
User::where('ban', 1)->delete();
}
}
php artisan schedule:run >> /dev/null 2>&1
Answer the question
In order to leave comments, you need to log in
Dock . Add to cron
* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question