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

kykyleoh's avatar

Help: Artisan scheduled commands don't execute.

I need to run an API call daily. To do this, I've created a command that executes this API call. Additionally, I've added the following to my routes/console.php file:

Schedule::command(FetchAPICommand::class)->daily();

I have also confirmed using php artisan schedule:list that the command is scheduled to run correctly.

However, it does not seem to actually run the command? I've tried changing the schedule to every minute and placed a logger inside the command to write a message to the log file when it runs but it still does not work. Even the inspire quote does not write to my log file.

I have tried manually calling my command using php artisan app:fetch-api and this works!

I don't know what I'm doing wrong. Please help

0 likes
4 replies
LaryAI's avatar
Level 58

It sounds like you've set up your command and scheduling correctly, but the scheduled tasks are not being executed. This is a common issue and is often related to the cron job that is supposed to trigger Laravel's task scheduler. Here are the steps to ensure everything is set up correctly:

  1. Ensure the Command is Registered: Make sure your command is registered in the app/Console/Kernel.php file. It should look something like this:

    protected $commands = [
        \App\Console\Commands\FetchAPICommand::class,
    ];
    
  2. Check the Schedule Definition: Ensure that your schedule definition in app/Console/Kernel.php is correct. It should look something like this:

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('app:fetch-api')->daily();
    }
    
  3. Set Up the Cron Job: Laravel's task scheduler needs to be triggered by a cron job. You need to set up a cron job that runs every minute to trigger the Laravel scheduler. You can do this by adding the following line to your server's crontab file:

    * * * * * php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
    

    You can edit the crontab file by running crontab -e in your terminal.

  4. Check Server Timezone: Ensure that your server's timezone matches the timezone configured in your Laravel application (config/app.php). Mismatched timezones can cause the scheduler to run at unexpected times.

  5. Check Logs: Check your Laravel logs (storage/logs/laravel.log) and your server's cron logs to see if there are any errors or messages that can give you more information about why the command is not running.

  6. Test with a Simple Command: To ensure that the scheduler is working, you can test with a simple command like the inspire command. Add this to your schedule method in app/Console/Kernel.php:

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('inspire')->everyMinute();
    }
    

    Then check your logs to see if the inspire quote is being logged every minute.

By following these steps, you should be able to identify and resolve the issue with your scheduled command not executing. If the problem persists, please provide more details about your environment and any error messages you are seeing.

nday's avatar

Probably someone will met with this problem too, while trying to figure out how to make it working google will take you here. I'm using Laragon as a server with built-in Cronical. The only working solution so far is to put next command into Cronical file:

* * * * * cmd.exe /c "cd /d F:\laragon\www\site.loc && php artisan schedule:run >> storage\logs\cron.log 2>&1"

and run as an administrator it from powershell at F:\laragon\bin\cronical\cronical.exe

Please or to participate in this conversation.