Get fresh content from StatelyWorld

Laravel’s task scheduler allows you to automate repetitive jobs like clearing logs, sending emails, and updating data. On Linux, this is handled via cron, but on Windows, we can replicate this behavior using Task Scheduler.

This guide shows you how to configure Laravel’s scheduler on Windows using either Herd or XAMPP as your PHP environment.

Step 1: Locate Your PHP Executable

You need the full path to the PHP executable used by your Laravel environment. Here’s how to find it:

Option A: Using Herd

Herd installs PHP here by default:

C:\Users\YourUsername\AppData\Local\Programs\Herd\php\php.exe

You can confirm this path from the Herd app → SettingsPHPReveal in File Explorer.

Option B: Using XAMPP

If you’re using XAMPP, PHP is typically located at:

C:\xampp\php\php.exe

Universal Tip:

Open Command Prompt and run:

where php

This will return the path Windows uses when calling

php

from the terminal. Use that in the next step.

Step 2: Open Windows Task Scheduler

  1. Press Windows + S and search for Task Scheduler
  2. Click Create Basic Task…
  3. Name it something like Laravel Scheduler

Step 3: Set the Trigger

  1. Choose Daily and set any time (e.g., 12:00 AM)
  2. Once created, right-click the task and click Properties
  3. Go to the Triggers tab and click Edit
  4. Check:
    • Repeat task every: 1 minute
    • For a duration of: 1 day

Step 4: Set the Action

Under the Actions tab:

  • Program/script: Enter the full path to your PHP executable
  • Add arguments:
    artisan schedule:run >> schedule.log 2>&1
  • Start in: Enter the full path to your Laravel project directory

Example for Herd:

  • Program/script:
    C:\Users\YourUsername\AppData\Local\Programs\Herd\php\php.exe
  • Start in:
    C:\Users\YourUsername\Sites\your-laravel-app

Example for XAMPP:

  • Program/script:
    C:\xampp\php\php.exe
  • Start in:
    C:\xampp\htdocs\your-laravel-app

Step 5: Enable Privileges

In the General tab of your task:

  • Check “Run whether user is logged on or not”
  • Check “Run with highest privileges”

Step 6: Test the Task Manually

Open Command Prompt and try the command manually:

cd C:\Path\To\Your\Laravel\Project
C:\Full\Path\To\php.exe artisan schedule:run

If it runs without errors, the Task Scheduler setup should work too.

Troubleshooting: What If You See 0x1 ?

The Last Run Result: 0x1 means something is misconfigured. Most likely causes:

  • “Start in” field is missing or incorrect
  • PHP path is wrong
  • artisan command is not found due to wrong working directory

Final Tip: Check Laravel Logs

You can confirm that tasks are running by logging something in your

App\Console\Kernel.php

:

      protected function schedule(Schedule $schedule)
      {
          $schedule->call(function () {
              \Log::info('Laravel scheduler ran!');
          })->everyMinute();
      }

Check

storage/logs/laravel.log

to verify it worked.

You’re Done!

With this setup, Laravel will now run scheduled tasks every minute just like a Linux cron job — but right on your Windows machine using Herd or XAMPP.

What is a Large Language Model (LLM)? — A Simple Guide for Everyone
Auto Login in Laravel Using Middleware and URL Token

Share This Post !

Leave A Comment