How to run task scheduler in windows 10 with Laravel

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
# Bridging the Gap: Running Laravel Tasks via Windows Task Scheduler As a senior developer, I frequently encounter scenarios where we need to bridge the gap between standard Linux/Laravel scheduling mechanisms (like Cron) and native Windows operating system features (like Task Scheduler). The core confusion often stems from the fact that while both systems handle time-based execution, their underlying mechanisms are fundamentally different. This post will walk you through the developer-centric approach to setting up scheduled tasks on a Windows machine to execute Laravel commands, effectively creating a custom cron substitute for your local environment. ## Understanding the Scheduling Divide: Cron vs. Windows Task Scheduler The reason this process feels complex is that Cron is a native time-based job scheduler built into Unix-like systems (Linux, macOS), designed to run scripts directly via the shell. Windows uses the **Task Scheduler**, which manages system-level events and application execution. To make them work together for Laravel tasks, we cannot simply use a standard cron entry. Instead, we must use the Task Scheduler as a *trigger* to execute a wrapper script or command that invokes the PHP interpreter and your Artisan commands. ## Step-by-Step Implementation Guide Running a scheduled task requires careful configuration, especially concerning environment variables and execution paths. ### Phase 1: Preparing the Execution Script Before setting up the scheduler, we need a reliable script to execute. This script will handle invoking the necessary PHP binaries in a controlled manner. Create a file named `run_laravel_task.bat` (or `.ps1` for PowerShell) in an easily accessible location. **Example Batch Script (`run_laravel_task.bat`):** ```batch @echo off REM Change directory to your Laravel project root cd C:\path\to\your\laravel\project\ REM Execute the Artisan command using the PHP executable path "C:\php\php.exe" artisan schedule:run >> C:\logs\task_log.txt 2>&1 ``` **Developer Note:** Notice how we explicitly call the full path to `php.exe`. This prevents errors that occur when the scheduler tries to find the executable in its limited PATH environment, which is a common pitfall when dealing with system scheduling versus interactive terminal sessions. ### Phase 2: Configuring the Windows Task Scheduler 1. **Open Task Scheduler:** Search for "Task Scheduler" in the Start menu. 2. **Create New Task:** Click "Create Basic Task" or "Create Task" for more advanced options. 3. **Trigger:** Set the trigger (e.g., Daily at 3:00 AM). 4. **Action:** Set the action to "Start a program." 5. **Program/Script:** Enter the full path to your wrapper script you created in Phase 1 (e.g., `C:\Scripts\run_laravel_task.bat`). Ensure that the task runs under an account that has sufficient permissions to access the project files and execute PHP. ## Best Practices for Laravel Scheduling When dealing with background jobs, especially within a framework like Laravel, stability is paramount. While this method works perfectly for local machine tasks, remember that relying solely on the operating system scheduler can introduce complexities related to environment setup. For production environments, it is often recommended to use dedicated task queue systems (like Redis queues managed by Laravel Horizon) or robust Linux-based cron setups, as these offer better visibility into job failures and dependency management. However, for local development, mastering this Windows Task Scheduler bridge gives you excellent control over local automation. As we build out our application ecosystem with tools like those provided by the [Laravel Company](https://laravelcompany.com), understanding these underlying system mechanics is crucial for seamless deployment. ## Conclusion Running Laravel tasks via the Windows Task Scheduler is entirely achievable by creating a reliable execution wrapper script. By treating the scheduler as an external trigger, rather than a native cron replacement, you gain control over the environment variables and execution context, ensuring your scheduled jobs run reliably on your local machine. This approach successfully bridges the gap between operating system automation and application-level workflow management.