Run cron jobs
Cron is a service mode for scheduled work: nightly imports, cleanup jobs, report generation. The container starts on a schedule you set, runs to completion, and takes no HTTP traffic.
Create a cron job
- Create a web service the usual way — from a Git repository, a container image, or an uploaded archive. Your container should run the job and exit when the work is done.
- Click the service on the environment canvas to open its drawer and go to the Settings tab.
- In the Deploy section, turn on Run on a schedule.
- The console pre-fills a daily schedule (
0 0 * * *) — replace it with your own 5-field cron expression, for example0 2 * * *. - Press Deploy on the changes bar (Shift+Enter). Mode changes are staged like any other spec edit.
While you type, the console reads the schedule back in words and shows a countdown to the next run, so a typo is visible before you deploy.
The schedule
A cron expression has five fields: minute, hour, day of month, month, day of week.
| Expression | Runs |
|---|---|
0 2 * * * | Every day at 02:00 |
0 * * * * | Every hour, on the hour |
0 9 * * 1 | Mondays at 09:00 |
A schedule is always required in cron mode — through the API, a cron service without one is rejected.
How runs behave
Once deployed, the service's health shows Scheduled — registered and waiting for its next tick. On each tick, Koo starts your container; the run ends when your process exits.
A cron service takes no HTTP traffic and can never be exposed — it has no public URL. If you switch an exposed service to cron mode, its public networking is turned off.
The replica count doesn't apply in cron mode: each tick starts one run in each of the service's locations, and nothing runs between ticks.
Logs
Each run's output lands in the service's Logs tab, like any other service — see logs.
Use variables and databases
Variables work normally in cron mode, including connection variables — so a cron job can use your database, for example a nightly job that works through rows in Postgres. See connect a database.