Schedule icon
Log icon

Executes flow on schedule trigger with a DayWeek when expression

Run Kestra flows on specific days of the week using a Schedule trigger `when` expression. Automate weekday or weekend-restricted workflows with precise scheduling control.

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

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

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

Run a Kestra flow on a recurring cron schedule, then gate each execution so it only proceeds on a specific weekday. This blueprint pairs the io.kestra.plugin.core.trigger.Schedule trigger with a when Pebble expression to fire at 11am every day, while only allowing the run to continue when the trigger date is a Monday. It solves the common scheduling problem where a single cron expression cannot express calendar-aware rules like "run only on Mondays" without brittle workarounds, giving you precise, declarative control over which days a workflow actually executes.

How it works

  1. The schedule trigger of type io.kestra.plugin.core.trigger.Schedule evaluates the cron expression 0 11 * * *, which marks every day at 11am as a candidate execution time.
  2. Before an execution is created, the trigger evaluates its when expression, {{ dayOfWeek(trigger.date) == 'MONDAY' }}, which compares the trigger date's day of week against MONDAY.
  3. If the trigger date is a Monday, the execution proceeds. On any other day the expression is false and no execution is created.
  4. When the run proceeds, the hello task of type io.kestra.plugin.core.log.Log writes a demo message confirming the when expression matched.

What you get

  • A working pattern for combining a daily cron schedule with a day-of-week gate.
  • Calendar-aware scheduling without custom date parsing or branching logic.
  • A clear, auditable trigger definition expressed entirely in declarative YAML.
  • A starting point you can adapt to any weekday or set of weekdays.

Who it's for

  • Data engineers running pipelines that should fire only on specific weekdays.
  • Platform teams standardizing scheduling patterns across many flows.
  • Anyone who has hit the limits of a plain cron expression for calendar rules.

Why orchestrate this with Kestra

A raw cron scheduler can express "every day at 11am" but cannot cleanly say "only when that day is a Monday" without encoding it into the cron string itself, which quickly becomes unreadable for multi-weekday or exclusion rules. Kestra separates the schedule from the calendar rule, so the cadence and the day-of-week check each stay legible. On top of that you get event-driven triggers, automatic retries, full execution lineage, and a declarative YAML definition that lives in version control. The trigger's when expression fills the gap a tool's own scheduler leaves open: readable, composable day-of-week logic layered on a standard cron schedule using the dayOfWeek() Pebble function.

Prerequisites

  • A running Kestra instance.

Secrets

This blueprint references no secrets.

Quick start

  1. Add this flow to your Kestra instance.
  2. Leave it enabled so the schedule trigger evaluates daily at 11am.
  3. On the next Monday at 11am, confirm an execution is created and the hello task logs its message.
  4. Verify that no execution is created on other days.

How to extend

  • Change dayOfWeek to any weekday, for example FRIDAY, to shift the allowed day.
  • Extend the when expression with or to allow a set of weekdays, for example {{ dayOfWeek(trigger.date) == 'MONDAY' or dayOfWeek(trigger.date) == 'FRIDAY' }}.
  • Adjust the cron expression to change the time of day or frequency.
  • Replace the hello Log task with real work such as a data load, API call, or notification.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.