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

bencarter78@hotmail.com's avatar

Running schedule:run on Windows

Hi all

Is it possible to use the schedule command on a windows machine? If I run artisan schedule:run from my command line I get an error saying...

php artisan mailman:test > dev/null 2>&1 &
The system cannot find the path specified

It seems that this is something within the Laravel core however I only want to run this for a cron job so I have a scheduled task running this as someone suggested trying after a google...

php artisan mailman:test > NUL 2>&1

But this isn't working for me either. Does anyone have any experience of this? Can anyone give me a few ideas?

Thanks

0 likes
14 replies
toniperic's avatar

I don't think you can as Laravel Scheduler uses a single cron job to handle everything, and there's no such thing as cron jobs on Windows. There is a Windows Scheduler built-in for scheduling tasks on Windows, but its not the same thing as cron jobs on UNIX, so I'm afraid you can't use it out of the box with Laravel Scheduler.

You can set up a virtual machine and run Linux on it. That way you can leverage Laravel Scheduler on the virtual machine. Search for Homestead section in the official Laravel docs.

bencarter78@hotmail.com's avatar

@toniperic I knew someone was going to say that!

I've got my hands tied behind my back with what I've got to use so I'll just have to set up a load of scheduled tasks then.

Thanks

Kryptonit3's avatar

@bencarter78

This is possible with Windows Task Scheduler but the downside is the lowest it can be set to is Every 5 Minutes which is still ok for a testing environment.

I created a batch file scheduler.bat with the following contents

cd c:\lamp\www\cw5
C:\lamp\bin\php\php-5.6.3\php.exe artisan schedule:run 1>> NUL 2>&1

Change directorys to match your setup. My project root is cw5

If you have php successfully added to your PATH variable then the second line can read php artisan..... no need for an exact location. But you will need to make sure you cd to your project root first.

Then launch the task scheduler Windows Key + R then paste in Taskschd.msc and hit enter.

Then click Create Basic Task on the right in the Actions pane.

Name your task something so you will know what it is for if you need to modify it or are running multiple projects then click Next.

Leave this page set to Daily for now and click Next.

Leave this page as defaults as well and click Next.

Make sure Start a Program is selected and click Next.

Browse to the batch file we just created and then click Next then click Finish.

Now, select Task Scheduler Library on the left, and find your task in the middle pane and right-click and click Properties

Go to the Triggers tab, click Daily in the list and click Edit.

The drop-down at the top next to Begin the task change to At Log on for Any user

Check the box that says Repeat Task Every and choose 5 Minutes from the drop-down. The drop-down after for a duration: on the same line choose Indefinitely.

Click OK. Done.

Then right-click on your task in the middle pane and click Run to initiate it.

33 likes
aragorn_cn's avatar

@bencarter78 @Kryptonit3 Kryptonit3's answer is excellent. One thing to add is that Windows Task Scheduler can set to repeat every 1 Minutes. You just select the 5 Minutes from the drop-down and change 5 to 1 manually.

8 likes
cvlug's avatar

how can be known if Kryptonit3's solution works? i followed your steps, and put, and put a long (sleep(100); ) in de schedule() function in file \laravel\vendor\laravel\framework\src\Illuminate\Foundation\Console\kernel.php. But when i run the task in taskplanner, the task finish allmost direcly. So i thing your solutions i not working on my Windows server 2008. I tried to execute the scheduler.bat from command line as well with "C:\php\php.exe D:\phpsites\touristpreview\laravel\scheduler.bat". This is what i see in the command windows: "cd D:\phpsites\touristpreview\laravel" it looks like the scheduler.bat does not get executed, but only its content gets displayed. Anybody please have a solution?

Thanks in advance

Tabun's avatar

@cvlug You can test this by removing the 1>> NUL 2>&1 parameters (temporarily). You should see the output from the commands now, if you run the .bat manually. If you do not see some output from the artisan command (like "No scheduled commands are ready to run" or the like), then something's wrong. It's easier to debug that way.

cris's avatar

Dear @Kryptonit3, thank you very much for your help, everything worked smoothly for my mails with Mailtrap testing and developing with Laragon. Greetings from Chile.

Javed71's avatar

@Kryptonit3 @Tabun Where does the batch file actually stored ?

I have executed the following command as you said but don't have any idea where the batch file actually stored ..

C:\> cd xampp/htdocs/blog

cd c:/xampp/php/php.exe artisan emails:send 1>> NUL 2>&1

sumonmselim's avatar

@Javed71 store the batch file anywhere you want it to be. Make sure while creating the task schedule, you choose/select it from the exact location.

AydenWH's avatar

Hi guys,

I still cannot make it work by using the Task Scheduler method (taught by @Kryptonit3) to run the .bat file. (I tried to run it manually and automatically from Task Scheduler) Although the command is running smoothly without any error but I did not see any record was added into database.

If I ran it by double clicking the .bat file and it works like charm. Record was added into database as well.

I tried these following commands:

cd D:\Workspace\XAMPP\htdocs\webminder
php artisan schedule:run 1>> NUL 2>&1
timeout /t 5
cd D:\Workspace\XAMPP\htdocs\webminder
D:\Workspace\XAMPP\php\php.exe artisan schedule:run 1>> NUL 2>&1
timeout /t 5

May I know what is the reason behind?

johdougss's avatar

@Tyris

Select the correct driver D:

cd D:\Workspace\XAMPP\htdocs\webminder
D:
php artisan schedule:run 1>> NUL 2>&1
timeout /t 5

Please or to participate in this conversation.