cron

Attribute Macro cron 

Source
#[cron]
Expand description

Marks a function as a scheduled cron task.

Cron jobs run on a schedule, exactly once per scheduled time across the cluster.

§Attributes

  • timezone = "UTC" - Timezone for the schedule
  • catch_up - Run missed executions after downtime
  • timeout = "1h" - Execution timeout

§Example

#[forge::cron("0 0 * * *")]
#[timezone = "UTC"]
#[catch_up]
pub async fn daily_cleanup(ctx: &CronContext) -> Result<()> {
    // ...
}