Motia Icon
ConceptsSteps

Cron Step

The Cron Step allows you to schedule your steps to run at specified intervals. It is a powerful tool for automating your business logic.

Config

The following properties are specific to the Cron Step, in addition to the common step config.

PropTypeDescription
string
The cron schedule expression for your step

The following examples showcase how to configure an CRON Step

import { CronConfig } from 'motia'
 
export const config: CronConfig = {
  type: 'cron' as const,
  name: 'PeriodicJob',
  description: 'Runs every minute and emits a timestamp',
  cron: '0 * * * *', // run every hour at minute 0
  emits: ['cron-ticked'],
  flows: ['cron-example'],
}
 
export const handler: StepHandler<typeof config> = async ({ emit }) => {
  await emit({
    topic: 'cron-ticked',
    data: { message: 'Cron job executed' },
  })
}
Need help? See our Community Resources for questions, examples, and discussions.

On this page