kubiya_scheduled_task
resource allows you to create and manage scheduled tasks in the Kubiya platform. Scheduled tasks execute Kubiya agents on defined schedules using cron expressions, enabling automated recurring operations for monitoring, reporting, maintenance, and other routine activities.
Scheduled tasks are essential for automating recurring operations like health checks, backups, reports, and maintenance tasks, ensuring consistent operations without manual intervention.
Prerequisites
Before using this resource, ensure you have:- A Kubiya account with API access
- An API key (generated from Kubiya dashboard under Admin → Kubiya API Keys)
- At least one configured agent to execute
- Understanding of cron expression syntax
Quick Start
Configuration Examples
Schedule comprehensive weekly reporting tasks:
Advanced Configurations
Multi-Environment Scheduling
Multi-Environment Scheduling
Create scheduled tasks across different environments with varying frequencies:
Conditional Task Execution
Conditional Task Execution
Create tasks that perform different actions based on conditions:
Compliance and Audit Tasks
Compliance and Audit Tasks
Schedule compliance checking and audit tasks:
Arguments Reference
Required Arguments
The name of the scheduled task. Must be unique within your organization.
A description of the scheduled task’s purpose and functionality.
The name of the agent to execute when the task runs.
Cron expression defining when the task should run. Format: “minute hour day month weekday”.
The prompt to send to the agent when the task executes. This guides the agent’s actions.
Optional Arguments
Whether the scheduled task is enabled and will execute on schedule.
Notification configuration for task execution results:
Notification method. Available options:
Slack
- Send notifications to Slack channelsEmail
- Send email notificationsHttp
- Send HTTP webhook notificationsTeams
- Send Microsoft Teams notifications
Destination for notifications:
- Slack: Channel name with ”#” prefix or username with ”@” prefix
- Email: Email address or distribution list
- Http: Webhook URL for HTTP notifications
- Teams: Channel name within the specified team
Team name for Microsoft Teams notifications. Required when method is “Teams”.
Cron Expression Reference
The schedule uses standard cron expression format:Attributes Reference
In addition to all arguments above, the following attributes are exported:The unique identifier of the scheduled task.
The timestamp when the scheduled task was created.
The timestamp when the scheduled task was last updated.
The timestamp of the last execution.
The timestamp of the next scheduled execution.
The current status of the scheduled task.
Import
Scheduled tasks can be imported using their ID:Best Practices
Scheduling Strategy
- Be aware that schedules run in UTC; adjust accordingly for your timezone
- Avoid overly frequent schedules that may overwhelm the system
- Schedule intensive tasks during off-peak hours
- Consider business hours and maintenance windows when setting schedules
Task Design
- Design tasks to be idempotent to handle potential reruns safely
- Include error handling and recovery logic in agent prompts
- Use clear, specific prompts that define expected outcomes
- Test schedules in development before production deployment
Monitoring & Alerts
- Configure appropriate notifications for critical tasks
- Monitor task execution history and success rates
- Set up alerts for task failures or missed executions
- Use different notification channels for different types of tasks
Documentation & Maintenance
- Document the purpose and expected behavior of each task
- Include contact information for task owners
- Regular review and cleanup of obsolete scheduled tasks
- Version control your scheduled task configurations
Notification Methods
Compatibility
Requirements:
- Kubiya Terraform Provider version >= 1.0.0
- Terraform >= 1.0
- Cron expressions are evaluated in UTC by default
- Agent must exist and be accessible before task creation
Limitations:
- Minimum schedule frequency may be limited by platform tier
- Very frequent schedules (e.g., every minute) may be subject to rate limiting
- Task execution time limits apply based on your platform configuration
- Notification delivery depends on integration configuration
Troubleshooting
Schedule Not Executing
Schedule Not Executing
- Verify the cron expression syntax is correct
- Check that the task is enabled
- Ensure the agent exists and is accessible
- Review timezone considerations (schedules run in UTC)
- Check platform limits on schedule frequency
Agent Execution Issues
Agent Execution Issues
- Verify the agent name exactly matches an existing agent
- Check that the agent has proper permissions and integrations
- Ensure the prompt is clear and actionable
- Review agent instructions for task compatibility
Notification Problems
Notification Problems
- Verify notification method configuration
- Check destination format (channels, emails, URLs)
- Ensure integrations are properly configured
- Test notification channels independently