Schedules
Weik.io 2026.2A Camel route starts on a timer or a cron, and a schedule document runs a command, curl or a script on an agent at set times in UTC. Product page · Video
Watch: Running an integration on a schedule, 3:15
The video runs an integration on a cron schedule.
On this page
There are two ways to run something at set times. A Camel integration starts its route with Camel’s own timer: or quartz: component. A schedule document runs a command on an agent, such as curl for a URL, a script or any program the agent’s host has, and you write no route for it.
A route on a timer or a cron#
A timer starts the route at a fixed interval:
- route:
from:
uri: timer:tick?period=60000
steps:
- to: "{{erp-url}}/api/invoices/pending"
- to: direct:transformCamel’s quartz: component starts it on a cron. The cron has six fields, starting with the seconds:
- route:
from:
uri: quartz:payroll/nightly
parameters:
cron: "0 0 2 * * ?"
trigger.timeZone: UTC
steps:
- to: direct:run-nightly-payrollA polling route like these should run in one copy at a time when two agents run the integration. One copy at a time shows how.
A schedule that runs a command#
A schedule has a cron, a command and its arguments:
apiVersion: weik.io/v1
kind: schedule
metadata: { name: nightly-cleanup, project: finance }
spec:
cron: "0 0 2 * * ?"
command: bash
args: ["-c", "/opt/scripts/cleanup.sh"]weikio init nightly-cleanup --kind schedule writes a schedule that runs bash -c with an echo at 02:00 UTC, with a comment where a site’s script goes. Apply and deploy it like any integration:
$ weikio apply -f ./finance/schedules/nightly-cleanup.yaml
$ weikio deploy finance/nightly-cleanup --env productionThe agent runs the command on its own host, so give the schedule requirements when the script exists on some hosts only, such as requirements: { site: factory }. A schedule runs one copy at a time by default, so the command runs once even when two agents match.
What a run leaves#
The command’s standard output and standard error go into the deployment’s logs line by line. When the command fails, an error line says how it ended, such as The command exited with 3. or The command exited with 3: <standard error>. A command that couldn’t start says why in the operating system’s own words.
$ weikio logs finance/nightly-cleanup --env production --since 24hA run whose command failed counts as a failed message in weikio status, weikio metrics and the admin UI.
Run it now#
weikio invoke runs the command at once, outside the cron, and prints what it printed:
$ weikio invoke finance/nightly-cleanup --env devtest --endpoint direct:scheduleUTC, and the schedule in words#
Every schedule’s times are UTC. The admin UI shows a cron in words beside its expression, such as Every 30 seconds (0/30 * * * * ?, from close-cron). The cron can come from a variable, cron: "{{close-cron}}", so devtest and production run on different times. Then the page shows the name of that variable and says when an environment has no value for it.