services
Cron Job
Schedule tasks to run at specific times using cron syntax.
A cron job runs your code on a schedule. The container starts, executes your task, and stops. Perfect for periodic cleanup, report generation, backups, or any recurring task.
When to Use#
- Scheduled database cleanup or maintenance
- Periodic report generation and emails
- Data synchronization between systems
- Automated backups
- Health checks or monitoring probes
Configuration#
runix.yaml
yaml
services:
- name: cleanup
type: cron-job
repo: https://github.com/alice/maintenance-scripts
cron_schedule: "0 3 * * *"
env:
DATABASE_URL: "${db.connection_string}"Available Fields#
| Field | Default | Description |
|---|---|---|
| `repo` | — | GitHub repository URL (required) |
| `branch` | `main` | Git branch to deploy |
| `cron_schedule` | — | Cron expression (required for cron-job type) |
| `instance` | `starter` | Instance type |
| `build_command` | Auto-detected | Override the build command |
| `start_command` | Auto-detected | Override the start command |
| `env` | None | Environment variables |
Cron Syntax#
The `cron_schedule` field uses standard 5-field cron syntax:
text
┌───────────── minute (0-59)
│ ┌───────────── hour (0-23)
│ │ ┌───────────── day of month (1-31)
│ │ │ ┌───────────── month (1-12)
│ │ │ │ ┌───────────── day of week (0-6, Sunday=0)
│ │ │ │ │
* * * * *Common Schedules#
| Expression | Meaning |
|---|---|
| `* * * * *` | Every minute |
| `0 * * * *` | Every hour |
| `0 3 * * *` | Every day at 3:00 AM UTC |
| `0 0 * * 1` | Every Monday at midnight UTC |
| `0 0 1 * *` | First day of every month at midnight |
| `*/15 * * * *` | Every 15 minutes |
All cron schedules run in UTC. Adjust your times accordingly.
Keep cron jobs short. If your task takes longer than the interval between runs, you may end up with overlapping executions.