Schedule icon
Log icon

Executes flow on schedule trigger with Or condition

Combine multiple Kestra schedule conditions with the Or operator. Trigger a workflow whenever any one of several configured cron conditions is satisfied.

Categories
Core
id: schedule-condition-or
namespace: company.team

triggers:
  - id: schedule
    type: io.kestra.plugin.core.trigger.Schedule
    cron: "0 11 * * *"
    when: "{{ (dayOfWeek(trigger.date) == 'MONDAY') or (dayOfWeek(trigger.date) ==
      'THURSDAY') }}"

tasks:
  - id: hello
    type: io.kestra.plugin.core.log.Log
    message: Demo for Or condition

Plain cron expressions cannot say "run this only on Mondays or Thursdays" in a single, readable line. This blueprint shows how to gate a standard cron trigger with a when Pebble expression on the Schedule trigger, combining two day-of-week checks with the or operator so the flow fires when either one evaluates to true. It is a clean pattern for selective scheduling, business-calendar logic, and multi-rule time windows without writing custom date math.

How it works

  1. A io.kestra.plugin.core.trigger.Schedule trigger evaluates daily at 11am using the cron expression 0 11 * * *.
  2. The trigger's when property holds the expression {{ (dayOfWeek(trigger.date) == 'MONDAY') or (dayOfWeek(trigger.date) == 'THURSDAY') }}.
  3. Each side of the or calls dayOfWeek(trigger.date) and compares it against MONDAY and THURSDAY respectively.
  4. Because or requires only one side to be true, the flow executes at 11am on Mondays and on Thursdays, and is skipped on every other day.
  5. When the condition passes, the hello task (io.kestra.plugin.core.log.Log) runs and emits a confirmation message to the logs.

What you get

  • A reusable template for conditional scheduling without complex cron hacks.
  • Day-of-week gating driven by {{ trigger.date }} so logic stays declarative.
  • A working example of or inside a when expression to combine multiple independent triggering rules.
  • A safe, side-effect-free demo task you can swap for real work.

Who it's for

  • Data engineers who need flows to run only on specific business days.
  • Platform teams standardizing scheduling patterns across many flows.
  • Anyone who finds raw cron hard to read or maintain for calendar logic.

Why orchestrate this with Kestra

A raw scheduler can only express a single cron pattern; it cannot easily combine "Mondays or Thursdays or month-end" without brittle expressions or duplicate jobs. Kestra lets you attach a single declarative when expression to one trigger and combine as many checks as you need with or (or and), all in version-controlled YAML. You also gain automatic retries, full execution lineage, and event-driven extensibility that a bare cron entry cannot provide.

Prerequisites

  • A running Kestra instance.

Secrets

This flow uses no secrets.

Quick start

  1. Add this flow to your Kestra instance.
  2. Confirm the schedule trigger is enabled.
  3. Wait for 11am on a Monday or Thursday, or backfill the trigger to test.
  4. Check the execution logs for the message from the hello task.

How to extend

  • Add more dayOfWeek(...) comparisons chained with or, or mix in a date/time range check for time windows.
  • Switch the or operators to and to require every check to pass.
  • Replace the Log task with real work such as a query, an API call, or a subflow.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.