Workers, cron jobs, and task scheduling

Laravel offers a very convenient and flexible way of scheduling tasks. A large set of helper functions help you schedule commands and jobs.

Once the scheduled tasks are defined, they need to be effectively executed at the right time and pace. The recommended way is a cron configuration entry running the artisan schedule:run command.

.platform.app.yaml
crons:
    # Run Laravel's scheduler every 5 minutes, which is as often as crons can run on Professional plans.
    scheduler:
        spec: '*/5 * * * *'
        cmd: 'php artisan schedule:run'

The minimum time between cron jobs being triggered depends on your plan. Task scheduling may then be contradicted by the cron minimum frequency. Schedules outside the specified cron frequency are ignored and the related tasks aren’t triggered.

This blog post may help you understand the stakes and harmonize the frequencies so all your scheduled tasks can be effectively triggered.

You could also configure a worker that relies on artisan schedule:work. To invoke the scheduler every minute, run the following command:

.platform.app.yaml
workers:
   queue:
       size: S
       commands:
           start: php artisan schedule:work