User Documentation

Workers, cron jobs, and task scheduling

Sign up for Upsun

Get your free trial by clicking the link below.

Get your Upsun free trial

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 schedule for every minute. However, on the minimum time between cron jobs 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.

Due to this conflict, we suggest utilizing workers to run both the scheduler and the queue systems (the Laravel template utilizes this method). In order to have enough resources to support these workers as well as services (e.g. MariaDB, Redis, etc), a Medium plan or greater is required.

To use workers to handle scheduling and queues add the following to your file:
    size: S
      # To minimize leakage, the queue worker will stop every hour
      # and get restarted automatically.
      start: |
        php artisan queue:work --max-time=3600        
    disk: 256
    size: S
      start: php artisan schedule:work
    disk: 256

Is this page helpful?