Cron Trigger (Scheduled Task)
The Cron Trigger enables automatic workflow execution at precise times based on cron expressions.
What does this integration do?
The Cron Trigger starts workflows according to a scheduled timeline. It uses cron expressions to define complex schedules - from simple hourly executions to complex, condition-dependent schedules.
Typical Use Cases:
- Report Generation: Create automatic daily, weekly, or monthly reports
- Data Processing: Regular processing of large datasets
- System Maintenance: Automated maintenance tasks and cleanup operations
- Monitoring: Regular system checks and health monitoring
- Backup Processes: Automated data backups at scheduled times
User Configuration
Basic Configuration
Cron Expression
- Purpose: Defines the schedule for workflow execution
- Format: Standard cron syntax with 5 or 6 fields
- Examples:
0 9 * * * # Daily at 9:00 AM
0 */6 * * * # Every 6 hours
0 0 * * 1 # Every Monday at midnight
30 14 1 * * # 1st of every month at 2:30 PM
0 8 * * 1-5 # Weekdays at 8:00 AM
*/15 * * * * # Every 15 minutes
Timezone - Optional
- Purpose: Determines the timezone for cron execution
- Default: Server system timezone
- Examples:
Europe/Berlin
America/New_York
Asia/Tokyo
UTC
Result (Timestamp) - Variable for timestamp
- Purpose: Name of the variable that stores the execution timestamp
- Content: ISO timestamp of trigger execution
- Usage: Can be used in subsequent workflow steps
- Example:
triggerTime→ stores "2024-03-15T09:00:00.000Z"
Cron Expression Help
Field Meanings:
* * * * * *
│ │ │ │ │ │
│ │ │ │ │ └─ Day of week (0-7, Sunday = 0 or 7)
│ │ │ │ └─── Month (1-12)
│ │ │ └───── Day of month (1-31)
│ │ └─────── Hour (0-23)
│ └───────── Minute (0-59)
└─────────── Second (0-59, optional)
Special Characters:
*- Any value (every minute, every hour, etc.)*/5- Every 5 units (every 5 minutes, every 5 hours, etc.)1,3,5- Specific values (minute 1, 3, and 5)1-5- Range (Monday to Friday for weekdays)0 9-17 * * 1-5- Weekdays from 9-17 every hour
Common Patterns:
0 0 * * * # Daily at midnight
0 */1 * * * # Hourly
*/30 * * * * # Every 30 minutes
0 9,17 * * 1-5 # Weekdays at 9:00 and 17:00
0 2 * * 0 # Sundays at 2:00 AM
0 0 1 * * # Monthly on 1st at midnight
0 0 1 1 * # Yearly on January 1st at midnight
Workflow Integration
Data Provision
The Cron Trigger provides the following data for the workflow:
Timestamp Variable
- Name: As defined in configuration
- Format: ISO 8601 timestamp
- Timezone: UTC or as configured
- Example: "2024-03-15T09:00:00.000Z"
Usage in Subsequent Steps
Example usage of timestamp variable:
Variable: triggerTime
Value: 2024-03-15T09:00:00.000Z
Using in LLM Action:
"Create a report for the period until {{triggerTime}}"
Using in HTTP Action:
URL: https://api.example.com/reports?date={{triggerTime}}
Practical Examples
Daily Report at 9:00 AM
Configuration:
- Cron Expression:
0 9 * * * - Timezone:
Europe/Berlin - Result:
reportTime
Usage: Generates daily reports at 9:00 AM Central European Time
Weekday Reminder
Configuration:
- Cron Expression:
0 8 * * 1-5 - Timezone:
Europe/Berlin - Result:
reminderTime
Usage: Sends reminders or starts check processes on weekdays at 8:00 AM
Weekly Backup
Configuration:
- Cron Expression:
0 2 * * 0 - Timezone:
UTC - Result:
backupTime
Usage: Starts backup process on Sundays at 2:00 AM UTC
Monitoring Every 15 Minutes
Configuration:
- Cron Expression:
*/15 * * * * - Result:
checkTime
Usage: Checks system status every 15 minutes
Technical Details
Schema Configuration
configSchema: {
cronExpression: {
name: 'Cron Expression',
schema: z.string()
},
timezone: {
name: 'Timezone',
schema: z.string().optional()
},
outputName: {
name: 'Result (Timestamp)',
reference: 'memory-out',
schema: z.string(),
},
}
Internal Implementation
Cron Engine:
- Uses
node-cronlibrary for precise scheduling - Fallback to
setIntervalwhen node-cron is not available - Automatic timezone handling
- Robust error handling for invalid expressions
Timestamp Generation:
- Generates ISO 8601 formatted timestamps
- Considers configured timezone
- Makes timestamps available in workflow memory
Resource Management:
- Minimal CPU usage between executions
- Automatic cleanup on stop
- Supports multiple parallel cron triggers
Validation and Error Handling
Cron Expression Validation:
- Syntax verification before activation
- Helpful messages for invalid expressions
- Support for 5 and 6 field formats
Timezone Handling:
- Validation of timezone names
- Fallback to system timezone for invalid values
- Support for all IANA timezone designations
Error Scenarios:
- Invalid cron expressions are rejected
- Unknown timezones fall back to UTC
- System errors are logged and reported
Best Practices
Scheduling
Resource Optimization:
- Avoid too frequent executions (under 1 minute) unless necessary
- Distribute regular jobs across different times
- Consider system load when scheduling
Timezone Management:
- Use explicit timezone specifications for production environments
- Consider daylight saving time changes
- Document timezone decisions for the team
Workflow Design
Robustness:
- Implement error handling in scheduled workflows
- Consider that jobs might run multiple times simultaneously
- Plan for different execution times (time zone changes)
Monitoring:
- Monitor execution times of scheduled workflows
- Set alerts for failed scheduled executions
- Document expected execution frequencies
Maintenance
Cron Expression Management:
- Test complex cron expressions before production use
- Document the meaning of each cron expression for the team
- Use online tools to validate complex expressions
Performance Monitoring:
- Monitor resource usage during frequent executions
- Optimize workflows for fast execution with repeated jobs
- Schedule resource-intensive jobs outside peak hours
The Cron Trigger is the foundation for time-based automation in Vectense Platform and enables precise, reliable scheduled workflow execution.