Cron Trigger
Time-based workflow triggering with flexible scheduling patterns and timezone support
Cron Trigger
The Cron trigger enables time-based workflow execution using standard cron expression syntax. It provides reliable, scheduled automation for recurring tasks, reports, maintenance jobs, and periodic data processing.
Configuration
Input Schema
Field | Type | Required | Description |
---|---|---|---|
cronExpression | string | Yes | Standard cron expression (5 or 6 fields) |
timezone | string | No | IANA timezone identifier (defaults to UTC) |
defaultInput | object | No | Default data to pass to the workflow |
Basic Configuration
triggers:
daily_report:
type: "cron"
input:
cronExpression: "0 9 * * 1-5" # 9 AM on weekdays
timezone: "America/New_York"
defaultInput:
reportType: "daily"
includeMetrics: true
Cron Expression Syntax
Cron Expression Builder: Use crontab.guru to easily build and validate your cron expressions. This interactive tool helps you visualize when your cron jobs will run and catch syntax errors before deployment.
Cron expressions use 5 or 6 fields separated by spaces:
┌───────────── minute (0 - 59)
│ ┌─────────── hour (0 - 23)
│ │ ┌───────── day of month (1 - 31)
│ │ │ ┌─────── month (1 - 12)
│ │ │ │ ┌───── day of week (0 - 6) (Sunday to Saturday)
│ │ │ │ │
* * * * *
Special Characters
Character | Description | Example |
---|---|---|
* | Any value | * * * * * (every minute) |
, | Value list separator | 0,30 * * * * (every 30 minutes) |
- | Range of values | 0 9-17 * * * (every hour 9 AM to 5 PM) |
/ | Step values | */15 * * * * (every 15 minutes) |
? | No specific value | 0 0 ? * MON (Mondays at midnight) |
Common Patterns
# Every minute
cronExpression: "* * * * *"
# Every hour at 30 minutes past
cronExpression: "30 * * * *"
# Daily at 2:30 AM
cronExpression: "30 2 * * *"
# Weekdays at 9 AM
cronExpression: "0 9 * * 1-5"
# Every Sunday at 3 AM
cronExpression: "0 3 * * 0"
# First day of every month at midnight
cronExpression: "0 0 1 * *"
Pattern Examples
# Every minute
cronExpression: "* * * * *"
# Every hour at 30 minutes past
cronExpression: "30 * * * *"
# Daily at 2:30 AM
cronExpression: "30 2 * * *"
Basic recurring patterns for frequent automation tasks and regular monitoring.
# Weekdays at 9 AM
cronExpression: "0 9 * * 1-5"
# Every Sunday at 3 AM
cronExpression: "0 3 * * 0"
# First day of every month at midnight
cronExpression: "0 0 1 * *"
Perfect for weekly reports, monthly billing processes, and weekend maintenance tasks.
# Every 15 minutes during business hours
cronExpression: "*/15 9-17 * * 1-5"
# Lunch break automation (12:30 PM weekdays)
cronExpression: "30 12 * * 1-5"
# End of business day (5:30 PM weekdays)
cronExpression: "30 17 * * 1-5"
Ideal for business process automation, status updates, and team notifications during working hours.
# Quarterly: first day of quarter at 6 AM
cronExpression: "0 6 1 1,4,7,10 *"
# Bi-weekly on Mondays and Thursdays
cronExpression: "0 9 * * 1,4"
# Every 6 hours starting at midnight
cronExpression: "0 */6 * * *"
Complex scheduling patterns for quarterly reports, multi-day cycles, and sophisticated automation workflows.
Advanced Scheduling
# Send status updates every 2 hours during business hours
triggers:
business_hours_update:
type: "cron"
input:
cronExpression: "0 */2 9-17 * * 1-5"
timezone: "America/New_York"
defaultInput:
updateType: "status"
audience: "team"
Perfect for automating tasks during working hours like status updates, notifications, and team communications. Ensures activities happen when people are available to respond.
# Global reports at local business hours
triggers:
us_morning_report:
type: "cron"
input:
cronExpression: "0 9 * * 1-5"
timezone: "America/New_York"
defaultInput:
region: "US"
eu_morning_report:
type: "cron"
input:
cronExpression: "0 9 * * 1-5"
timezone: "Europe/London"
defaultInput:
region: "EU"
asia_morning_report:
type: "cron"
input:
cronExpression: "0 9 * * 1-5"
timezone: "Asia/Tokyo"
defaultInput:
region: "ASIA"
Essential for global teams and services. Run the same schedule at appropriate local times across different regions for consistent user experience.
# Summer schedule (May-September)
triggers:
summer_maintenance:
type: "cron"
input:
cronExpression: "0 2 * 5-9 6" # Saturdays at 2 AM, May-Sept
timezone: "UTC"
defaultInput:
season: "summer"
maintenanceType: "light"
# Winter schedule (October-April)
triggers:
winter_maintenance:
type: "cron"
input:
cronExpression: "0 2 * 10-12,1-4 6" # Saturdays at 2 AM, Oct-Apr
timezone: "UTC"
defaultInput:
season: "winter"
maintenanceType: "heavy"
Adapt scheduling based on seasons, business cycles, or varying operational needs. Useful for maintenance windows, resource allocation, and seasonal campaigns.
Common Use Cases
# Generate and send daily analytics report
triggers:
daily_analytics:
type: "cron"
input:
cronExpression: "0 8 * * 1-5" # 8 AM weekdays
timezone: "America/Los_Angeles"
defaultInput:
reportType: "analytics"
recipients: ["[email protected]"]
timeframe: "yesterday"
# Sync data every 4 hours
triggers:
data_sync:
type: "cron"
input:
cronExpression: "0 */4 * * *"
defaultInput:
syncType: "incremental"
sources: ["database", "api", "files"]
# Daily database backup
triggers:
daily_backup:
type: "cron"
input:
cronExpression: "0 3 * * *" # 3 AM daily
defaultInput:
backupType: "full"
retention: "7days"
# Weekly cleanup on Sunday nights
triggers:
weekly_cleanup:
type: "cron"
input:
cronExpression: "0 2 * * 0" # Sundays at 2 AM
defaultInput:
cleanupTasks: ["logs", "temp_files", "old_backups"]
retentionDays: 30
# System health check every 15 minutes
triggers:
health_check:
type: "cron"
input:
cronExpression: "*/15 * * * *"
defaultInput:
checkType: "system"
services: ["api", "database", "cache"]
alertOnFailure: true
Best Practices
Scheduling Guidelines
- Avoid peak hours: Schedule resource-intensive tasks during off-peak times
- Consider dependencies: Ensure dependent workflows run in the correct order
- Use appropriate frequencies: Don't over-schedule unnecessary tasks
- Plan for maintenance windows: Schedule around known system maintenance
# Good: Off-peak scheduling
triggers:
data_processing:
type: "cron"
input:
cronExpression: "0 2 * * *" # 2 AM when traffic is low
# Avoid: Peak hour scheduling
triggers:
heavy_processing:
type: "cron"
input:
cronExpression: "0 12 * * *" # Noon when traffic is high
Timezone Management
- Be explicit: Always specify timezone when time matters
- Consider users: Use timezone appropriate for your audience
- Document assumptions: Make timezone choices clear in comments
- Handle DST: Be aware of daylight saving time changes
# Good: Explicit timezone
triggers:
user_notification:
type: "cron"
input:
cronExpression: "0 9 * * 1-5"
timezone: "America/New_York" # Clear timezone
# Avoid: Ambiguous timing
triggers:
unclear_timing:
type: "cron"
input:
cronExpression: "0 9 * * 1-5" # What timezone?
Monitoring and Debugging
Cron Context Variables
Access scheduling information in your workflows:
# Available cron context
- "{{ trigger.scheduledTime }}" # When it was supposed to run
- "{{ trigger.actualTime }}" # When it actually ran
- "{{ trigger.cronExpression }}" # The cron expression
- "{{ trigger.timezone }}" # The configured timezone
- "{{ trigger.defaultInput }}" # The default input provided
Execution Monitoring
# Log cron execution details
- id: log_cron_execution
type: script
input:
script: |
console.log('Cron Execution:', {
expression: trigger.cronExpression,
scheduled: trigger.scheduledTime,
actual: trigger.actualTime,
delay: new Date(trigger.actualTime) - new Date(trigger.scheduledTime),
timezone: trigger.timezone
});
Common Issues & Solutions
Summary
The Cron trigger is essential for creating reliable, time-based automation that keeps your systems running smoothly and your data up to date.
Last updated on