The following are instructions for running scheduled tasks defined in a Laravel project on Windows. The Laravel documentation provides instructions for running scheduled tasks using cron jobs on Linux systems. However, cron jobs are not available on Windows. The built-in Windows Task Scheduler can be used to run scheduled tasks instead.
- Open Task Scheduler
- Select Create Task...
- Give the task a name and description
- To run the task in the background, select Run whether the user is logged on or not and check the Hidden checkbox.
- Create a new trigger.
- Set the trigger to run Daily and recur every
1
days. - Set Repeat task every to
1 minutes
.1 minutes
is not a selectable option. Simply select5 minutes
from the dropdown and then manually edit. - Set for a duration of: to
Indefinitely
. - Ensure that Enabled is checked.
- Create a new action.
- Start php by entering the php binary location, such as
C:\php\php.exe
- Set Add arguments field to
C:\{project-dir}\artisan schedule:run
(replace{project-dir}
with appropriate path).
- Check Allow task to be run on demand.
- Check Run task as soon as possible after a scheduled start is missed.
- To ensure that the task is running, find the task in the Task Scheduler Library.
- Note the task Status. It may be Ready or Running.
- Note the Next Run Time and Last Run Time properties.