Reference » Primitives » App

Timer

A Timer spawns a Process on a schedule that is defined using cron syntax.

Definition

A Timer is defined in convox.yml.

services:
  worker:
    build: ./worker
timers:
  cleanup:
    command: bin/cleanup
    schedule: "0 3 * * *"
    service: worker

Attributes

Name Required Description
command yes The command to execute once the Process starts
schedule yes A cron formatted schedule for spawning the Process. All times are UTC
service yes The name of the Service that will be used to spawn the Process

Cron Expression Format

Cron expressions use the following format. All times are UTC.

.----------------- minute (0 - 59)
|  .-------------- hour (0 - 23)
|  |  .----------- day-of-month (1 - 31)
|  |  |  .-------- month (1 - 12) OR JAN,FEB,MAR,APR ...
|  |  |  |  .----- day-of-week (0 - 6) OR SUN,MON,TUE,WED,THU,FRI,SAT
|  |  |  |  |
*  *  *  *  *

Using a Template Service

Timers can run against any Service, even one that is scaled to zero. You can use this to create a template Service for your Timers.

services:
  web:
    build: .
    command: bin/web
    port: 5000
  jobs:
    build: ./jobs
    scale: 
      count: 0
timers:
  cleanup:
    command: bin/cleanup
    schedule: "*/2 * * * *"
    service: jobs

On this App the jobs Service is scaled to zero and not running any durable Processes.

The cleanup Timer will spawn a Process of the jobs Service to run bin/cleanup once every two minutes.