Automation5 min read

How Do Dagster Schedules and Sensors Automate Pipelines?

Dagster schedules and sensors are the two classic ways to launch pipeline runs automatically. Schedules trigger work at fixed times defined by cron expressions, while sensors watch for events, such as a new file or an updated upstream asset, and request runs when something changes. Together with declarative automation, they let teams move from manual clicks to dependable, hands-off pipelines.

Automation only works when the background daemon is running. In local development, dagster dev starts it for you, while production deployments run it as a dedicated service so schedules and sensors are evaluated continuously.

Creating a Schedule

A schedule needs a target and a cron expression. The target is usually an asset job, which is a named selection of assets. The cron expression defines when the job runs, such as every morning or every hour.

from dagster import ScheduleDefinition, define_asset_job

daily_job = define_asset_job("daily_job", selection="*")

daily_schedule = ScheduleDefinition(
    job=daily_job,
    cron_schedule="0 6 * * *",
    execution_timezone="Europe/London",
)

Add the schedule to your Definitions, then switch it on in the UI. Each evaluation is recorded as a tick, so you can see exactly when the schedule fired and which run it launched.

Handling time zones

Cron expressions are ambiguous without a time zone. Setting an explicit execution time zone avoids surprises around daylight saving changes and makes schedules easier to reason about for teams spread across regions.

Creating a Sensor

Sensors are Python functions that the daemon calls at a regular interval. Each evaluation can return run requests, skip with a reason or update a cursor that tracks progress between evaluations.

from dagster import RunRequest, sensor

@sensor(job=daily_job)
def new_file_sensor(context):
    for filename in list_new_files(context.cursor):
        yield RunRequest(run_key=filename)

The run key prevents duplicate runs for the same event. If the sensor sees the same filename twice, Dagster recognises the key and skips launching another run.

Choosing Between Schedules, Sensors and Declarative Automation

Each approach fits a different situation. Many projects combine all three, using schedules for predictable reporting, sensors for external events and declarative automation for keeping derived assets fresh.

ApproachTriggerBest for
ScheduleFixed times via cronDaily reports, regular batch loads
SensorCustom event checksNew files, API changes, external systems
Asset sensorMaterialisation of a specific assetReacting to upstream data updates
Declarative automationConditions on assetsKeeping downstream assets in sync automatically

Using Declarative Automation

Declarative automation attaches conditions directly to assets. Instead of scheduling a job, you describe when an asset should update, for example whenever its upstream dependencies have new data or on a cron cadence. Dagster evaluates those conditions and launches runs only when they are met.

This approach reduces wasted compute because assets refresh only when needed. It also keeps the automation logic next to the asset definition, which makes intent clearer for anyone reading the code.

Partitions and Backfills

Time-partitioned assets pair naturally with schedules. A daily partitioned asset can be scheduled so that each run processes the latest partition. When historical data needs reprocessing, a backfill launches runs for a range of partitions from the UI.

  • Use daily or hourly partitions for event and transaction data.
  • Launch backfills in manageable ranges to control warehouse load.
  • Monitor backfill progress in the UI and retry failed partitions.
  • Keep partition definitions consistent across related assets.

Monitoring Automated Runs

Automation still needs oversight. The UI shows schedule ticks, sensor evaluations and run outcomes, making it easy to spot a sensor that keeps skipping or a schedule that stopped. Alerting on failed runs ensures problems reach the right people quickly.

Keep sensors fast and lightweight, since slow evaluations delay every subsequent check. Move heavy work into the runs themselves and let sensors focus on deciding whether a run is needed.

Reliability checklist

Confirm the daemon is healthy, schedules are switched on and time zones are explicit. Review sensor cursors after outages, and test new automation in a staging environment before enabling it in production.

Asset Sensors for Cross-Team Dependencies

Asset sensors watch a specific asset and react whenever it is materialised. They are useful when one team's output triggers another team's work, especially across separate code locations. The downstream team can start processing as soon as fresh data lands, without guessing a schedule.

This pattern decouples teams while keeping data flowing. Each team owns its assets and automation, and the sensor forms a clear, visible contract between them.

Run Status Sensors and Alerts

Run status sensors respond to the outcome of other runs. A failure sensor can send a message to a chat channel or open a ticket, while a success sensor can trigger follow-up work. These sensors turn routine monitoring into automated responses.

  • Notify the owning team when a critical job fails.
  • Trigger a downstream job only after an upstream run succeeds.
  • Record run outcomes in an external monitoring system.

Testing Automation Before Production

Schedules and sensors are code, so they can be tested. Sensor functions can be called with a test context to verify which run requests they produce, and schedules can be evaluated for specific times. Testing automation logic prevents surprises such as duplicate runs or missed triggers after deployment.

Enabling new automation in a staging environment first adds another layer of safety. Watch a few ticks, confirm the expected runs appear and only then switch the automation on in production.

Common Scheduling Mistakes

A few recurring mistakes cause most automation problems. Forgetting to start the daemon means nothing runs at all, while missing time zones cause runs to fire an hour early or late after clock changes. Sensors that perform heavy work slow down every evaluation.

  • Schedules switched off after a deployment and never re-enabled.
  • Overlapping schedules that launch the same assets twice.
  • Sensors without run keys, causing duplicate runs for the same event.

Conclusion

Dagster schedules provide predictable, time-based automation, while sensors and declarative automation respond to events and data changes. Combine them thoughtfully, set explicit time zones, keep sensors lightweight and monitor every tick and run. With those practices in place, pipelines run on their own and your team spends more time improving data rather than launching jobs.