Jobs
A job runs one action over many devices: a firmware upgrade, a settings change, a reboot. You name the action and the devices. The job starts them in waves, inside a time window in each device’s own time zone. It pauses itself when too many fail.
Each device runs the action as an ordinary action. Its
steps, lanes, results and action.result event work as for any other action.
You can use any action a device’s package offers. It can be a standard
action or one of the package’s own. A firmware upgrade, for example, is a
package action. Its firmware URL is a parameter you give it.
Run a job
Section titled “Run a job”-
Write a job file:
name = "volume down"action = "set_settings"params = { values = { volume = 70 } }[targets]select = "site = north"[rollout]waves = [1, "10%", "50%"] -
Create the job. The answer lists every device it matched:
Terminal window hourctl job create volume-down.toml -
Follow it:
Terminal window hourctl job show <ID>hourctl job list -
Act on it when needed:
hourctl job pause,resume,advance,cancelorretry-failed(commands).
The job file
Section titled “The job file”hourctl job create <file.toml> reads a TOML file. POST /api/tenants/{tenant}/jobs
takes the same fields as JSON. Unknown fields are refused.
name = "volume down" # for people; not uniqueaction = "set_settings" # what each device runsparams = { values = { volume = 70 } }lane = "interactive" # or "bulk"timeout = "30m" # seconds, or "90s", "30m", "2h", "1d"
[targets]select = "site = north and floor in (1, 2)"endpoints = ["office"]devices = ["lobby/<DEVICE>"] # "endpoint/device"
[rollout]waves = [1, "10%", "50%"]max_concurrent = 5advance = "auto" # or "manual"
[window]days = ["sat", "sun"]hours = "22:00-05:00"
[abort]failed_percent = 20after = 10| Field | Default | Meaning |
|---|---|---|
name | none | A name for people. Not unique. |
action | required | The action each device runs. |
params | {} | The action’s parameters, by name. |
lane | interactive | The lane each device’s action queues in: interactive or bulk. |
timeout | none | How long each device has, from when its action starts. Any positive duration. With none set, there is no deadline. |
targets | required | Which devices (targets). |
rollout.waves | one wave | Wave sizes (rollout). |
rollout.max_concurrent | no limit | Devices running at once, at least 1. |
rollout.advance | auto | auto or manual. |
window.days | every day | mon to sun, or the full names, in any case. |
window.hours | the whole day | HH:MM-HH:MM, local time. |
abort.failed_percent | none | 1 to 100 (abort). |
abort.after | 1 | Finished devices before the threshold applies. |
Targets
Section titled “Targets”The targets are resolved once, when the job is created. Give at least one
of select, endpoints and devices.
- With
selectorendpoints, the job takes the allowed devices of those endpoints. When no endpoint is named, it takes every endpoint. - Of those devices, it keeps the ones the selector
picks by their labels. Two examples are
site = north and floor in (1, 2)andregion ^= west/nevada and kind != kiosk. - A device’s labels are its endpoint’s labels, with its own labels laid over them. This works as in sync group placement.
- With
select, a selector that is not valid refuses the job. The refusal names its column. - An unknown endpoint in
endpointsrefuses the job. - The devices in
devicesare added. Those not known or not allowed are listed in the job’smissing.
The job’s matched says how many devices it runs on. Devices are taken in
(endpoint, device) order.
A job is refused (400) when:
- it matches no allowed device, or more than 100 000.
- the package of an endpoint it matched offers no such action or command.
- its parameters hold a value the action marks sensitive, such as a password or a key. A job keeps its parameters to start each device’s action. Send such values as individual actions instead.
- the action writes data that a matched endpoint’s sync group keeps. Write that data through the sync API instead.
Parameters are checked against the action’s declaration as each device’s
action starts. A device whose action cannot be started fails, and its
detail says why. This includes an action that carries biometric data of
a person their group refuses (biometrics).
Rollout
Section titled “Rollout”waves gives each wave’s size, in order. A size is one of:
- A count, such as
5. - A share of all matched devices, such as
"10%"(1% to 100%). It is rounded up and never less than one.
A size larger than the devices left takes what is left. Waves after the
devices run out are dropped. Devices left over after the last wave make
one more wave. Without waves, there is one wave of every device.
Devices of the current wave and of earlier waves start as
max_concurrent allows.
advance | The next wave starts when |
|---|---|
auto | Every device of the current wave succeeded (several waves may pass at once), or you run advance. |
manual | You run advance. |
advance moves to the next wave whatever became of the current one.
Window
Section titled “Window”Devices start only while the window is open in their own time zone. The window is open:
- on the
daysgiven (every day when none are given). - within the
hours(the whole day when none are given).
A window gives days, hours or both. The end of hours is excluded.
24:00 may end it. The same start and end means the whole day. Hours
that run past midnight belong to the day they start on. For example,
days = ["sat"] with hours = "22:00-05:00" is open from Saturday 22:00
to Sunday 05:00. A device already running continues when the window closes.
Each device’s zone is fixed when the job is created. It is the first of these that applies:
- its endpoint’s
timezoneoption; - else the
*/timezonesetting of its sync group, if the group keeps settings; - else UTC.
A zone is an IANA name (America/Chicago) or a fixed offset (+02:00).
The job’s no_zone counts devices with no zone of their own. It appears in
POST /api/tenants/{tenant}/jobs and GET /api/tenants/{tenant}/jobs/{id}.
hourctl job show shows their zone as UTC (none).
Timeout
Section titled “Timeout”A job with no timeout has no deadline. Each device’s action waits until
one of these happens:
- The device answers.
- Its commands are lost, either by the order of its answers or because its package says it restarted. See lost commands.
- You cancel the action or give up on it.
With a timeout, each device’s action is started with an expiry. The expiry
is timeout after the device starts. It happens at exactly that instant,
not after a wait:
- Steps not handed to the device are cancelled.
- Steps in the device’s hand are given up on, as when an app gives up. Each
ends unanswered, with its
command.unansweredevent. The action fails with them. - The device is
timed_out. An answer that comes later changes nothing for the job.
If the device answered that the action failed, the device is failed,
whenever it failed.
A held device is not handed its steps. The job
takes its action back. The device fails with the detail
the device is held: ....
A running job pauses when both of these are true:
afterdevices have finished. Succeeded, failed and timed out devices count as finished. Cancelled ones are not counted.failed_percentor more of the finished devices failed or timed out.
Its reason then reads, for example,
abort threshold: 3 of 10 finished devices failed or timed out (abort at 20%).
After a resume, the job pauses again only when more devices have failed
or timed out than when it was resumed.
States
Section titled “States”Device (execution) states
Section titled “Device (execution) states”| State | Meaning |
|---|---|
queued | Its wave has not started, or there is no room yet (max_concurrent). |
waiting_window | Its turn, but the window is closed in its zone. |
running | Its action is started. |
succeeded | Its action finished successfully. |
failed | Its action failed, or could not be started. |
timed_out | Its action did not finish by the job’s timeout. |
cancelled | The job was cancelled before it finished. |
An execution’s detail says what went wrong, as its action’s reason
does. An example is step 2 (verify) failed: the device answered -1.
Steps are counted from 1. Or detail says what the execution waits for.
An example is waiting for window (opens 2026-10-04 22:00 America/Chicago).
That is the window’s next opening in the device’s zone.
attempt starts at 1 and increases with each retry-failed. held is
shown when the device is held.
Job states
Section titled “Job states”| State | Meaning |
|---|---|
running | Devices start as the rollout and window allow. |
paused | No device starts. Devices already running continue to their end. |
cancelled | Devices not started never will be. |
completed | Every device has finished. A paused job also completes. |
The job’s reason says what paused or cancelled it. For a running job, it
says what the job waits for:
reason | Cause |
|---|---|
paused by <user> | pause |
cancelled by <user> | cancel |
abort threshold: ... | The abort threshold. |
wave 2 has devices that did not succeed: retry-failed, advance or cancel | A wave finished with failures. |
wave 1 succeeded: waiting to be told to advance | A manual wave succeeded. |
waiting for window (opens ...) | Nothing is running and devices wait for the window. |
Waves are numbered from 1 in these texts and in hourctl job show. They are
numbered from 0 in the wave field of the API and events.
Commands
Section titled “Commands”| Command | Applies to | Effect |
|---|---|---|
pause | a running job | No device starts. Those running continue to their end. |
resume | a paused job | The job runs again. |
advance | a running or paused job not at its last wave | The next wave may start, whatever became of the current one. |
cancel | a job not completed or cancelled | Devices queued or waiting are cancelled. The actions of running devices are taken back. Steps already handed out report as usual. The device ends as its action does. |
retry-failed | a job, not cancelled, with devices that failed or timed out | Those devices are queued again in their wave, as their next attempt with a new action. A completed job runs again. A paused one stays paused. |
A command that does not apply to the job as it is is answered 409, with the reason. You can send a command to any instance. It changes the job in the database, and the job’s leader continues from there.
Leaders and restarts
Section titled “Leaders and restarts”One instance runs each job at a time. Everything about the job is kept in the database:
- When that instance stops, another takes the job over where it was, within about 10 seconds.
- After a restart of the whole cluster, unfinished jobs continue.
- A device’s action is never started twice for the same attempt. Each
action carries
originjob:<id>.
A job’s first devices start just after it is created. The create answer
shows them still queued.
Events and audit
Section titled “Events and audit”A job reports what it does in events
(job events) with package
"houradvantage".
| Event | Sent to | When |
|---|---|---|
job.started | every endpoint the job has devices on (device "") | The job is created. |
job.paused | same | Paused by a command or the abort threshold. |
job.resumed | same | Resumed, or a completed job run again by retry-failed. |
job.wave | same | The current wave advanced. |
job.cancelled | same | Cancelled. |
job.completed | same | Every device finished. |
job.execution.started | the device’s endpoint | A device started. |
job.execution.succeeded | same | A device succeeded. |
job.execution.failed | same | A device failed. |
job.execution.timed_out | same | A device timed out. |
job.execution.cancelled | same | A device was cancelled. |
Job events carry job_id, action, state, wave, and name when
set. The job’s own events add waves, counts and reason. A device’s
events add attempt, action_id and detail. An endpoint may drop any
of them with drop_events. Each device’s action also sends its own
action.result, with origin job:<id>.
A sink that names no events is sent only job.paused and job.completed
of these. The others go only to a sink that names them
(the default set).
Every change made through the API is in the audit trail. A pause by the
abort threshold is recorded too, by user houradvantage, as job.paused.
API and hourctl
Section titled “API and hourctl”| API | hourctl |
|---|---|
POST /api/tenants/{tenant}/jobs (201, with every device it matched) | hourctl job create <file.toml> |
GET /api/tenants/{tenant}/jobs?limit= (newest first, 500 at most and by default) | hourctl job list |
GET /api/tenants/{tenant}/jobs/{id} (with every device in executions; 404 if unknown) | hourctl job show <id> |
POST /api/tenants/{tenant}/jobs/{id}/pause | hourctl job pause <id> |
POST /api/tenants/{tenant}/jobs/{id}/resume | hourctl job resume <id> |
POST /api/tenants/{tenant}/jobs/{id}/advance | hourctl job advance <id> |
POST /api/tenants/{tenant}/jobs/{id}/cancel | hourctl job cancel <id> |
POST /api/tenants/{tenant}/jobs/{id}/retry-failed | hourctl job retry-failed <id> |
Each job shows counts: how many devices are in each state. hourctl job show lists every device with its wave, state, attempt, action, zone and
detail. hourctl job list lists every job with its counts.