Upsun User Documentation

Workers, cron jobs, and task scheduling

Upsun Beta access

Test and provide feedback for our newest offering - Upsun!

You can register for the Beta by clicking here and completing the form.

Sign up for Beta access

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

Cron jobs Anchor to this heading

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.

Update the configuration of your Laravel container in the applications top-level key of your .upsun/config.yaml file.

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

The minimum time between cron jobs being triggered is 5 minutes. 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.

Workers Anchor to this heading

You could also configure a worker that relies on artisan schedule:work. To invoke the scheduler every minute, update the configuration of your Laravel container by adding the following command to the applications top-level key of your .upsun/config.yaml file.

.upsun/config.yaml
workers:
   queue:
       size: S
       commands:
           start: php artisan schedule:work

Worker resource allocation Anchor to this heading

Adding workers translates into new containers added to your Upsun project. Therefore, you have to explictly allocate resources for them:

upsun resources:set

Is this page helpful?