Log icon
Schedule icon
DayWeekInMonth icon

Executes flow on schedule trigger with DayWeekInMonth condition

Schedule a Kestra flow to run on the last Saturday of every month with the DayWeekInMonth condition on a Schedule trigger, for calendar rules cron cannot express.

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

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

triggers:
  - id: schedule
    type: io.kestra.plugin.core.trigger.Schedule
    cron: "0 11 * * *"
    conditions:
      - type: io.kestra.plugin.core.condition.DayWeekInMonth
        date: "{{ trigger.date }}"
        dayOfWeek: SATURDAY
        dayInMonth: LAST

Plain cron expressions cannot express calendar rules like "the last Saturday of every month" or "the second Tuesday." This blueprint shows how Kestra solves that with a daily io.kestra.plugin.core.trigger.Schedule trigger combined with the io.kestra.plugin.core.condition.DayWeekInMonth condition, so the flow evaluates every day at 11am but only actually runs when the trigger date lands on the last Saturday of the month. It is the canonical pattern for monthly, position-based scheduling (week-of-month plus day-of-week) that raw cron syntax simply does not support.

How it works

  1. The schedule trigger uses cron 0 11 * * *, which fires the evaluation every day at 11am.
  2. A conditions entry of type io.kestra.plugin.core.condition.DayWeekInMonth inspects {{ trigger.date }}.
  3. The condition is configured with dayOfWeek: SATURDAY and dayInMonth: LAST, so it returns true only on the last Saturday of the month.
  4. When the condition passes, the single hello task (io.kestra.plugin.core.log.Log) runs and logs a demo message. On every other day the condition is false and no execution is created.

What you get

  • A reusable recipe for "Nth weekday of the month" scheduling without brittle cron hacks.
  • Exactly one execution per month (last Saturday at 11am) instead of 30+ skipped runs.
  • A clear, declarative example you can drop real tasks into.

Who it's for

  • Data and platform engineers running monthly close, reporting, or maintenance jobs.
  • Teams whose business calendar is defined by week-of-month rules rather than fixed dates.
  • Anyone migrating fragile cron-only schedules into Kestra.

Why orchestrate this with Kestra

A standard scheduler can fire on a day of the month, but it cannot natively express "the last Saturday" or "the first Monday." Kestra closes that gap with declarative YAML conditions on top of the Schedule trigger, and adds retries, backfills, full execution lineage, and event-driven triggers around the same flow. You get position-based calendar logic plus production-grade orchestration in one place.

Secrets

This flow uses no secrets. The hello task only logs a message, so no credentials are required.

Prerequisites

  • A running Kestra instance.
  • Permission to register flows and schedule triggers in your target namespace.

Quick start

  1. Copy this blueprint into your namespace.
  2. Save the flow so the Schedule trigger is registered.
  3. Wait for the next last Saturday at 11am, or use a backfill to validate the condition immediately.
  4. Confirm an execution is created only on the matching date.

How to extend

  • Change dayOfWeek (for example MONDAY) and dayInMonth (FIRST, SECOND, THIRD, FOURTH, LAST) for other calendar rules.
  • Replace the hello Log task with your real workload: a database job, an export, or a downstream subflow.
  • Adjust the cron time to shift the daily evaluation window.
  • Combine with additional conditions to further narrow when the flow runs.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.