Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

brunokaue's avatar

How execute commands in Laravel 11

Improved Phrase:

I'm trying to schedule a simple test command in Laravel 11 to log the current timestamp every minute. I've created a command named 'app:test-command' that logs the timestamp using theLog::error method. However, when I schedule it to run every minute using Artisan::command and start the scheduler with php artisan schedule:work, the command isn't executing.

0 likes
5 replies
martinbean's avatar

@brunokaue Can you share some code? Show how and where you’re actually trying to schedule this command.

brunokaue's avatar

@martinbean in the command I have this code

public function handle(): void
    {
        Log::warning(now()->format('Y-m-d H:i:s'));
    }

I must call in /routes/console.php

Artisan::command('app:test-command', function () {
})->everyMinute();

I've started the php artisan schedule:work command, but nothing has happened.

JussiMannisto's avatar

@brunokaue Artisan::command() is for defining closure commands. You're passing it an empty closure, which is then scheduled and executed every minute. Use Schedule::command() instead to schedule an existing command:

use Illuminate\Support\Facades\Schedule;

Schedule::command('app:test-command')->everyMinute();
1 like

Please or to participate in this conversation.