Post

Cron Timer Condition

Trigger workflows on a schedule using cron expressions for time-based automation.

Cron Timer Condition

Cron Timer: Schedule-Based Workflow Triggers

The Cron Timer Condition enables schedule-based automation by triggering workflows at specific times using cron expressions. This is essential for creating time-based automation such as daily reports, periodic maintenance tasks, scheduled data collection, or recurring operations.

Info: This is a Trigger node type that can be used to trigger workflows based on events or conditions. When the scheduled time matches the cron expression, this trigger executes all of its child executor nodes.

Overview

Cron Timer leverages the power of cron expressions to provide flexible, precise scheduling capabilities. From simple daily tasks to complex multi-condition schedules, Cron Timer gives you full control over when your automation workflows execute.

Key Features

  • Standard Cron Syntax: Supports industry-standard cron expression format
  • Flexible Scheduling: Minutes, hours, days, months, and weekdays
  • Second-Level Precision: Enhanced cron with optional seconds field
  • Background Processing: Runs continuously in the background via CronScheduler
  • Multiple Schedules: Create multiple cron timers for different workflows
  • Reliable Execution: Persistent scheduling survives server restarts

Cron Expression Scheduling Flow

graph TD
    A[CronScheduler Service] --> B[Check All Cron Timers]
    B --> C{Expression Matches<br/>Current Time?}
    C -->|No| D[Wait for Next Check]
    C -->|Yes| E[Set Node to EXECUTED State]
    E --> F[Execute Child Executors]
    F --> G[Perform Automation Tasks]
    G --> D
    D --> B

Cron Expression Format

Standard cron expression with optional seconds:

1
2
3
4
5
6
7
8
9
┌───────────── second (0 - 59) [optional]
│ ┌───────────── minute (0 - 59)
│ │ ┌───────────── hour (0 - 23)
│ │ │ ┌───────────── day of month (1 - 31)
│ │ │ │ ┌───────────── month (1 - 12)
│ │ │ │ │ ┌───────────── day of week (0 - 6) (Sunday=0)
│ │ │ │ │ │
│ │ │ │ │ │
* * * * * *

Common Cron Expression Examples

ExpressionDescription
0 0 * * *Every day at midnight
0 */15 * * *Every 15 minutes
0 0 9 * * MON-FRIEvery weekday at 9 AM
0 0 0 1 * *First day of every month at midnight
0 30 8 * * *Every day at 8:30 AM
*/30 * * * * *Every 30 seconds (with seconds field)
0 0 12 * * SAT,SUNEvery weekend at noon

How It Works

The Cron Timer operates via the CronScheduler service:

  1. Registration: Cron Timer nodes register their expressions with the scheduler
  2. Continuous Monitoring: CronScheduler evaluates all expressions periodically
  3. Match Detection: When current time matches an expression, the timer fires
  4. Execution: Timer node transitions to EXECUTED state
  5. Child Execution: All child executor nodes are triggered
  6. Reset: Timer waits for the next scheduled occurrence

Configuration

FieldDescriptionRequired
expressionCron expression defining the scheduleYes

Use Cases

  • Data Collection: Schedule periodic sensor readings
  • Report Generation: Daily, weekly, or monthly automated reports
  • Maintenance Tasks: Regular system health checks or cleanup operations
  • Backup Operations: Scheduled data backup to external systems
  • Alert Schedules: Send notifications at specific times
  • Batch Processing: Process accumulated data at off-peak hours
  • Resource Management: Turn equipment on/off at scheduled times

Example Workflows

Daily Temperature Logging:

  1. Trigger: Cron Timer (0 0 0 * * * - midnight daily)
  2. Executor: Calculation (aggregate daily temperature data)
  3. Executor: OutgoingWebHook (send report to external system)

Periodic Sensor Reading:

  1. Trigger: Cron Timer (0 */5 * * * * - every 5 minutes)
  2. Executor: Lambda (read serial device sensor)
  3. Target: Update DataPoint with new reading

Weekday Morning Automation:

  1. Trigger: Cron Timer (0 0 7 * * MON-FRI - 7 AM weekdays)
  2. Executor: LogicGate (check conditions)
  3. Executor: Pin Control (turn on equipment)

Integration with Other Features

Cron Timer works seamlessly with:

  • Executors: Trigger calculations, computations, or webhooks on schedule
  • Data Points: Collect and log data at regular intervals
  • Lambda: Run Python scripts for complex scheduled tasks
  • Logic Gates: Conditional automation based on time and other factors

The Cron Timer Condition is fundamental for building reliable, automated time-based workflows in the Krill Platform.

This post is licensed under CC BY 4.0 by the author.