Looks like the user on production with which you are running php artisan schedule:run does not have permission to write in the log file, so that's why it fails.
If you just put echo 'Test'; instead of Log::info will it work?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have created a cron job in laravel 10. Runs fine in Dev but fails in prod. Looking for help on how to debug it
this is my kernel.php
class Kernel extends ConsoleKernel
{
protected function schedule(Schedule $schedule): void
{
$schedule->command('email:cron')
->everyFifteenMinutes();
}
protected function commands(): void
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
This is the cronfile, i have removed some for brevity. In prod I never see the log output in the handle() function
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'email:cron';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
Log::info("(".__LINE__.") ".__FILE__." -->".__METHOD__." Starting email Cron\n");
}
}
In the dev env, I get:
php artisan schedule:run
2024-03-06 20:49:06 Running ['artisan' email:cron] ........................1,008ms DONE
⇂ '/usr/bin/php8.2' 'artisan' email:cron > '/dev/null' 2>&1
In prod I get:
php artisan schedule:run
2024-03-06 20:52:58 Running ['artisan' email:cron]..................... 190ms FAIL
⇂ '/usr/bin/php8.2' 'artisan' email:cron > '/dev/null' 2>&1
Please or to participate in this conversation.