Scheduled behaviors allow you to execute RDE behaviors periodically according to a cron schedule. This feature enables automated, recurring operations on defined entities without manual intervention.
The scheduled behaviors functionality provides a built-in mechanism for periodic behavior execution within VMware Cloud Foundation Automation.
Scheduled behaviors use a dedicated RDE type (vmware:ScheduledBehaviorType:1.0.0) to persist scheduling state and configuration. When you schedule a behavior:
A scheduled behavior requires the following configuration:
The schedule is defined using standard cron expressions:
# Format: second minute hour day month weekday
0 0 2 * * * # Every day at 2:00 AM
0 */15 * * * * # Every 15 minutes
0 0 9 * * MON # Every Monday at 9:00 AM
The behavior to execute, identified by its URN:
urn:vcloud:behavior-interface:myBehavior:vendor:interface:1.0.0
For dynamic behaviors, the entity on which to invoke the behavior:
urn:vcloud:entity:vendor:type:entity-uuid
For static behaviors, this can be omitted.
Create a new scheduled behavior execution:
POST /cloudapi/1.0.0/scheduledBehaviors
Request body:
{
"configuration": {
"config": {
"cronExpression": "0 0 2 * * *",
"behaviorId": "urn:vcloud:behavior-interface:cleanup:mycompany:maintenance:1.0.0",
"entityId": "urn:vcloud:entity:mycompany:application:abc-123"
}
},
"arguments": {
"cleanupAge": 30,
"dryRun": false
}
}
Response:
{
"id": "urn:vcloud:entity:vmware:ScheduledBehaviorType:schedule-uuid",
"entityType": "urn:vcloud:type:vmware:ScheduledBehaviorType:1.0.0",
"name": "Scheduled cleanup behavior",
"entity": {
"configuration": {
"config": {
"cronExpression": "0 0 2 * * *",
"behaviorId": "urn:vcloud:behavior-interface:cleanup:mycompany:maintenance:1.0.0",
"entityId": "urn:vcloud:entity:mycompany:application:abc-123"
}
},
"state": {
"executionState": "ACTIVE",
"retryCounter": 0,
"lastExecutionTime": null,
"nextExecutionTime": "2024-01-16T02:00:00.000Z"
},
"arguments": {
"cleanupAge": 30,
"dryRun": false
}
},
"entityState": "RESOLVED"
}
Remove a scheduled behavior:
DELETE /cloudapi/1.0.0/scheduledBehaviors/<schedule-id>
This permanently deletes the schedule and stops all future executions.
Temporarily disable a schedule without deleting it:
POST /cloudapi/1.0.0/scheduledBehaviors/<schedule-id>/deactivate
The schedule record is retained but executions are paused. Can be reactivated later.
List all scheduled behaviors:
GET /cloudapi/1.0.0/entities/types/vmware/ScheduledBehaviorType/1.0.0
Filter by state:
GET /cloudapi/1.0.0/entities/types/vmware/ScheduledBehaviorType/1.0.0?filter=(entity.state.executionState==ACTIVE)
The scheduled behavior RDE maintains execution state including:
{
"state": {
"executionState": "ACTIVE",
"retryCounter": 0,
"maxRetries": 3,
"lastExecutionTime": "2024-01-15T02:00:00.000Z",
"nextExecutionTime": "2024-01-16T02:00:00.000Z",
"lastExecutionStatus": "SUCCESS"
}
}
When a scheduled behavior execution fails:
Configure retry behavior in the schedule:
{
"configuration": {
"retryConfig": {
"maxRetries": 3,
"retryDelay": 300
}
}
}
Query schedules in error state:
GET /cloudapi/1.0.0/entities/types/vmware/ScheduledBehaviorType/1.0.0?filter=(entity.state.executionState==RETRY)
Avoid overly frequent schedules that could impact system performance:
# Good: Every hour
0 0 * * * *
# Caution: Every minute (use sparingly)
0 * * * * *
Ensure your behavior logic handles cases where:
Design behaviors to be idempotent so re-execution doesn’t cause issues:
// Check if work already done
if (entity.lastProcessedDate > entity.lastModifiedDate) {
return { status: "already_processed" };
}
// Perform work
Regularly review:
Delete schedules that are no longer needed to reduce system overhead.
Schedule regular cleanup of temporary resources:
{
"cronExpression": "0 0 3 * * *",
"behaviorId": "urn:vcloud:behavior-interface:cleanup:app:maintenance:1.0.0"
}
Poll external systems for status updates:
{
"cronExpression": "0 */10 * * * *",
"behaviorId": "urn:vcloud:behavior-interface:pollStatus:app:monitor:1.0.0",
"entityId": "urn:vcloud:entity:app:deployment:xyz-789"
}
Generate periodic reports:
{
"cronExpression": "0 0 9 * * MON",
"behaviorId": "urn:vcloud:behavior-interface:generateReport:app:reporting:1.0.0"
}
Perform regular health checks on resources:
{
"cronExpression": "0 */5 * * * *",
"behaviorId": "urn:vcloud:behavior-interface:healthCheck:app:monitor:1.0.0"
}
This example shows scheduling a daily backup behavior:
POST /cloudapi/1.0.0/interfaces/urn:vcloud:interface:mycompany:backup:1.0.0/behaviors
{
"name": "dailyBackup",
"execution": {
"type": "WebHook",
"id": "backupWebhook",
"href": "https://backup-service.company.com/webhook",
"_internal_key": "shared-secret"
}
}
POST /cloudapi/1.0.0/scheduledBehaviors
{
"configuration": {
"config": {
"cronExpression": "0 0 1 * * *",
"behaviorId": "urn:vcloud:behavior-interface:dailyBackup:mycompany:backup:1.0.0",
"entityId": "urn:vcloud:entity:mycompany:database:prod-db-1"
},
"retryConfig": {
"maxRetries": 2
}
},
"arguments": {
"backupType": "full",
"retention": 7
}
}
Query execution history:
GET /cloudapi/1.0.0/entities/<schedule-id>
Check the state.lastExecutionTime and state.lastExecutionStatus fields.
Modify the cron expression or arguments:
PUT /cloudapi/1.0.0/entities/<schedule-id>
{
"entity": {
"configuration": {
"config": {
"cronExpression": "0 0 2 * * *"
}
}
}
}
Scheduled behavior operations require appropriate permissions:
Scheduled behaviors are designed for high availability: