Previous
Manage versions
Schedule automated jobs that call methods on your machine’s components and services at specified intervals. Use jobs to automate routine tasks like reading sensors, capturing images, running calibration routines, or syncing data.
Jobs are a good fit when you need to:
DoCommand routine with specific parameters on a scheduleIf you need conditional logic, coordination between multiple resources, or responses to events, write a logic module instead.
You can add a job to a single machine or to a fragment. Adding a job to a fragment deploys it to every machine that uses that fragment, which is the recommended approach for fleet-wide scheduling.
The job card has a Schedule section with three options:
Interval: run the job every N units of time. Select a number and a unit (milliseconds, seconds, minutes, hours, or days). For example, “every 5 minutes.”
Cron: run the job on a cron schedule. Enter a 5-field or 6-field cron expression. The UI shows a human-readable description of the schedule. Examples:
0 * * * * — every hour at the top of the hour0 9 * * 1-5 — every weekday at 9 AM*/5 * * * * * — every 5 seconds (6-field cron with seconds)Cron schedules are evaluated in the machine’s local timezone.
Continuous: run the job in an infinite loop. Each invocation starts immediately after the previous one completes. Use this for tasks that should always be running.
In the Job section:
DoCommand.DoCommand, a Command editor appears. Enter the JSON command to send:
{
"action": "calibrate",
"mode": "full"
}
In the Log threshold section, set the minimum log level for this job’s output:
Job execution logs appear under rdk.job_manager.{job-name} in the machine’s logs. At the default Info level, “Job triggered” and “Job succeeded” messages are at debug level and will not appear. Set the log threshold to Debug to see them.
In JSON mode, jobs are defined in the jobs array at the top level of the machine configuration:
{
"jobs": [
{
"name": "hourly-reading",
"schedule": "0 * * * *",
"resource": "my-sensor",
"method": "GetReadings"
},
{
"name": "calibration",
"schedule": "0 2 * * 0",
"resource": "my-sensor",
"method": "DoCommand",
"command": {
"action": "calibrate"
},
"log_configuration": {
"level": "debug"
}
}
]
}
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique name for the job. |
schedule | string | Yes | Cron expression (5 or 6 fields), Go duration string (for example, "30s", "5m", "1h"), or "continuous". |
resource | string | Yes | Name of the component or service to call. |
method | string | Yes | The API method to invoke on the resource. |
command | object | No | Arguments for DoCommand. Ignored for other methods. |
log_configuration | object | No | Set "level" to "debug", "info", "warn", or "error". |
Check the machine’s LOGS tab and filter for job_manager. Successful execution produces:
debug rdk.job_manager.hourly-reading Job triggered
debug rdk.job_manager.hourly-reading Job succeeded response map[...]
If the resource is not found:
warn rdk.job_manager.hourly-reading Could not get resource error could not find the resource for name my-sensor
Interval and cron jobs are singleton: only one instance runs at a time.
Continuous jobs restart immediately after each invocation. If the job function exits unexpectedly, it restarts after a 5-second delay.
viam-server is running. They do not persist across restarts (missed runs are not retried).DoCommand is the only method that supports arguments. All other methods are called without arguments (only the resource name is passed).Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!