Previous
Deploy software
Machine job scheduling is a preview feature. The configuration and functionality described here may change as the feature is developed.
Viam’s machine job scheduler allows you to configure automated jobs that run on your machines at specified intervals. This enables you to automate routine tasks such as data collection, sensor readings, maintenance operations, and system checks without manual intervention.
The job scheduler is built into viam-server
and executes configured jobs according to their specified schedules. Each job targets a specific resource on your machine and calls a designated method at the scheduled intervals.
Key features:
DoCommand
operationsJobs are configured as part of your machine’s configuration. Each job requires the following parameters:
Parameter | Type | Required | Description |
---|---|---|---|
name | string | Required | Unique identifier for the job within the machine |
schedule | string | Required | Schedule specification using unix-cron format or Golang duration |
resource | string | Required | Name of the target resource (component or service) |
method | string | Required | gRPC method to call on the target resource |
command | object | Optional | Command parameters for DoCommand operations |
The schedule
parameter accepts two formats:
Unix-cron expressions for time-based scheduling:
"0 */6 * * *"
- Every 6 hours"0 0 * * 0"
- Every Sunday at midnight"*/15 * * * *"
- Every 15 minutes"0 9 * * 1-5"
- Every weekday at 9 AMGolang duration strings for interval-based scheduling:
"5m"
- Every 5 minutes"1h"
- Every hour"30s"
- Every 30 seconds"24h"
- Every 24 hoursHere’s an example machine configuration with scheduled jobs:
{
"components": [
{
"name": "temp-sensor",
"model": "fake",
"type": "sensor"
},
{
"name": "camera1",
"model": "webcam",
"type": "camera"
}
],
"services": [
{
"name": "data_manager",
"type": "data_manager"
}
],
"jobs": [
{
"name": "hourly-sensor-reading",
"schedule": "0 * * * *",
"resource": "temp-sensor",
"method": "GetReadings"
},
{
"name": "daily-camera-capture",
"schedule": "0 8 * * *",
"resource": "camera1",
"method": "GetImage"
},
{
"name": "periodic-sync",
"schedule": "15m",
"resource": "data_manager",
"method": "Sync"
},
{
"name": "custom-maintenance",
"schedule": "0 2 * * 0",
"resource": "temp-sensor",
"method": "DoCommand",
"command": {
"action": "calibrate",
"mode": "full"
}
}
]
}
Schedule regular sensor readings or camera captures:
{
"name": "environmental-monitoring",
"schedule": "*/10 * * * *",
"resource": "environment-sensor",
"method": "GetReadings"
}
Run maintenance operations on a schedule:
{
"name": "weekly-calibration",
"schedule": "0 3 * * 0",
"resource": "imu-sensor",
"method": "DoCommand",
"command": {
"action": "calibrate"
}
}
Ensure regular data uploads to the cloud:
{
"name": "sync-data",
"schedule": "30m",
"resource": "data_manager",
"method": "Sync"
}
Monitor system status at regular intervals:
{
"name": "health-check",
"schedule": "0 */4 * * *",
"resource": "system-monitor",
"method": "DoCommand",
"command": {
"action": "health_check",
"include_logs": true
}
}
Use descriptive names that indicate the job’s purpose and frequency:
hourly-sensor-reading
daily-backup
weekly-maintenance
periodic-sync
Consider the following when planning job schedules:
Jobs should be designed to handle failures gracefully:
Test your job schedules thoroughly:
Monitor job execution through viam-server
logs. Look for:
Job not executing:
Resource not found:
Method not supported:
Schedule parsing errors:
viam-server
being running and connectedWas 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!