Schedules
Weik.io 2026.2Start a Camel route on a timer or a cron, or run a command on an agent at set times in UTC with a schedule document. Product page · Video
Watch: Running an integration on a schedule, 3:21
The video runs an integration on a cron schedule.
This part of the video couldn't be loaded.
On this page
A Camel integration can start its route at set times with Camel’s timer: or quartz: component. To run a command on an agent at set times without writing a route, use a schedule document. On a Linux agent, the command can be a script in the agent’s home folder /var/lib/weikio or any program the agent’s image has, such as curl for a URL. On a Windows agent, it can be any program the host has.
Timer and cron routes#
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:
- route:
from:
uri: quartz:payroll/nightly
parameters:
cron: "0 0 2 * * ?"
trigger.timeZone: UTC
steps:
- to: direct:run-nightly-payrollThe cron has six fields and starts with the seconds.
When two agents run the integration, a polling route like these should run one copy at a time.
Schedule a command#
A schedule document sets a cron and the command to run with its arguments:
apiVersion: weik.io/v1
kind: schedule
metadata: { name: nightly-cleanup, project: finance }
spec:
cron: "0 0 2 * * ?"
command: bash
args: ["-c", "/var/lib/weikio/scripts/cleanup.sh"]weikio init nightly-cleanup --kind schedule writes a schedule to start from. It runs an echo with bash -c at 02:00 UTC and marks with a comment where your script goes. Apply and deploy it like any integration:
$ weikio apply -f ./finance/schedules/nightly-cleanup.yaml
$ weikio deploy finance/nightly-cleanup --env productionOn a Linux agent the command runs in the agent’s container. The script must be in the agent’s home folder, /var/lib/weikio in the container. On the host, the sample’s /var/lib/weikio/scripts/cleanup.sh is /opt/weikio/<agent>/home/scripts/cleanup.sh. The agent’s user, uid 1654, must be able to read and run it. On a Windows agent the command runs on the host. When the script is on some agents only, give the schedule requirements that match them, such as requirements: { site: factory }. A schedule runs one copy at a time by default. 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. Every log line of a run carries the run’s ID. The last line says how the command ended, such as The command exited with 0. or The command exited with 3: <standard error>. When the command couldn’t start, the log has the operating system’s reason.
$ weikio logs finance/nightly-cleanup --env production --since 24hA run whose command failed counts as a failed message in the integration’s figures, such as those of weikio status and weikio metrics.
Each run also publishes a run record as an event in its environment, where other integrations can react to it. A run record says how the run went:
- The run’s start and end
- The command’s exit code
- Whether the run failed
A schedule built before 2026.2.2 records its runs once a new version of it is built and deployed.
An integration that receives a schedule’s run records is a reader like any other, so weikio reader skip and weikio reader rewind accept --schedule.
Check past runs#
To check a schedule’s past runs, open the Runs section of its page in the admin UI. On the Events page and in weikio events list, schedule runs have the family schedule:
$ weikio events list --env production --family schedule --integration finance/nightly-cleanup --since 24h --with-bodyWhere run records are kept#
Each environment has separate storage for run records. weikio env set --runs-bytes sets its size.
An agent that is cut off from the hub keeps on its host the run records the hub didn’t store, and publishes them oldest first when it reaches the hub again.
Run it now#
weikio invoke runs the command outside the cron and prints what the command printed:
$ weikio invoke finance/nightly-cleanup --env production --endpoint direct:scheduleTimes and crons#
Every schedule’s times are in UTC. To run devtest and production at different times, take the cron from a variable, as in cron: "{{close-cron}}".
The admin UI shows each cron in words beside its expression. For a cron from a variable you also see the variable’s name, as in Every 30 seconds (0/30 * * * * ?, from close-cron), and whether an environment has no value for it.