Platform.sh User Documentation

Workers, cron jobs, and task scheduling

Upsun Beta

Access our newest offering - 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 Platform.sh 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 .platform.app.yaml file:

.platform.app.yaml
workers:
  queue:
    size: S
    commands:
      # To minimize leakage, the queue worker will stop every hour
      # and get restarted automatically.
      start: |
        php artisan queue:work --max-time=3600        
    disk: 256
  scheduler:
    size: S
    commands:
      start: php artisan schedule:work
    disk: 256

Is this page helpful?