Scheduling
You’ll likely want to run various recurring tasks associated with your server. In the past, this may have been done utilizing cron
, but it can be frustrating to have your scheduling logic disconnected from your code. To make this easy, Alchemy provides a clean API for scheduling repeated tasks & jobs.
Scheduling
You can schedule recurring work for your application using the schedule()
function. You’ll probably want to do this in your boot()
function. This returns a builder with which you can customize the frequency of the task.
Scheduling Jobs
You can also schedule jobs to be dispatched. Don’t forget to run a worker to run the dispatched jobs.
Schedule frequencies
A variety of builder functions are offered to customize your schedule frequency. If your desired frequency is complex, you can even schedule a task using a cron expression.
Running the Scheduler
Note that by default, your app won’t actually schedule tasks. You’ll need to pass the --schedule
flag to either the serve
(default) or queue
command.