Skip to content

Instantly share code, notes, and snippets.

@iKlsR
Forked from Splode/Laravel-Scheduler-Windows.md
Created January 15, 2020 19:32
Show Gist options
  • Save iKlsR/9a616c283164f40a8b66bb8dab7ef2ca to your computer and use it in GitHub Desktop.
Save iKlsR/9a616c283164f40a8b66bb8dab7ef2ca to your computer and use it in GitHub Desktop.
Laravel Scheduler on Windows

Run Laravel Scheduled Tasks on Windows

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.

Create a Scheduled Task

  1. Open Task Scheduler
  2. Select Create Task...
  3. Give the task a name and description
  4. To run the task in the background, select Run whether the user is logged on or not and check the Hidden checkbox.

Triggers

  1. Create a new trigger.
  2. Set the trigger to run Daily and recur every 1 days.
  3. Set Repeat task every to 1 minutes. 1 minutes is not a selectable option. Simply select 5 minutes from the dropdown and then manually edit.
  4. Set for a duration of: to Indefinitely.
  5. Ensure that Enabled is checked.

Actions

  1. Create a new action.
  2. Start php by entering the php binary location, such as C:\php\php.exe
  3. Set Add arguments field to C:\{project-dir}\artisan schedule:run (replace {project-dir} with appropriate path).

Settings

  1. Check Allow task to be run on demand.
  2. Check Run task as soon as possible after a scheduled start is missed.

Wrap-up

  1. To ensure that the task is running, find the task in the Task Scheduler Library.
  2. Note the task Status. It may be Ready or Running.
  3. Note the Next Run Time and Last Run Time properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment