Hello everyone,
I'm working on a Laravel project where I'm using an Artisan console command to generate lottery draws (draws:generate) and a scheduler to ensure it runs at specific times (Tuesday, Thursday, and Saturday at 21:40). However, when I run the scheduler using the command sail artisan schedule:run -vvv, I receive the following output:
2025-01-25 21:40:00 Running ['artisan' draws:generate] ........................................... 495.31ms FAIL
⇂ '/usr/bin/php8.4' 'artisan' draws:generate > '/dev/null' 2>&1
What I've Done:
- I created a command draws:generate and registered it in App\Console\Commands.
- I also added the following Artisan command in the console.php:
<?php
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schedule;
// Rejestracja komendy Artisan
Artisan::command('draws:generate', function () {
$this->call('draws:generate');
})->purpose('Generowanie losowań');
// Scheduler w dni losowań (wtorek, czwartek, sobota) o 21:40
Schedule::command('draws:generate')->cron('40 21 * * 2,4,6');
Artisan::command('test:example', function () {
$this->info('Testowa komenda działa!');
});
Expected Behavior:
The draws:generate command should be executed at 21:40 on Tuesdays, Thursdays, and Saturdays without any errors.
Problem:
The command fails to run, as indicated by the FAIL status, but the error details are suppressed by the redirection (> '/dev/null' 2>&1).
Code in Commands/GenerateDraws
https://pastebin.com/KyxxLDb8
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.