Convox can set up cron-like recurring tasks on any of your application processes. This can be useful for background work like data dumps, batch jobs, or even queueing other background jobs for a worker.
Definition
timers:
cleanup:
command: bin/cleanup
schedule: "0 3 * * ? *"
service: web
You can think of a timer as issuing a convox run on the defined schedule. This timer would be equivalent to running convox run web --detach bin/cleanup at 3AM every day.
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 (1 - 7) OR SUN,MON,TUE,WED,THU,FRI,SAT
| | | | | .-- year (1970 - 2199)
| | | | | |
* * * * * *
Some example expressions:
See the Scheduled Events AWS documentation for more details.
Examples
Dedicated Service
Two services, web is normally running, timers is not (scaled to 0). The cleanup timer will spawn a new process using the configuration of timers once per minute, run the command bin/cleanup inside it, and terminate on completion.
services:
web:
build: .
command: bin/webserver
timers:
build: ./timers
scale: 0
timers:
cleanup:
command: bin/cleanup
schedule: "*/1 * * * ?"
service: timers
Existing Service
One service web is normally running. The cleanup timer will spawn a new process using the configuration of web one per minute, run the command bin/cleanup inside it, and terminate on completion.
services:
web:
build: .
command: bin/webserver
timers:
cleanup:
command: bin/cleanup
schedule: "*/1 * * * ?"
service: web