X Xerobit

AWS EventBridge Scheduler — Cron Schedules for Lambda and AWS Services

AWS EventBridge Scheduler runs Lambda functions, ECS tasks, and other AWS targets on a cron or rate schedule. Learn how to create schedules with cron expressions, handle...

Mian Ali Khalid · · 4 min read
Use the tool
Cron Builder
Build and parse cron expressions with human-readable explanations.
Open Cron Builder →

AWS EventBridge Scheduler (formerly CloudWatch Events) triggers AWS Lambda, ECS tasks, Step Functions, and 270+ other targets on a cron or rate schedule with timezone support.

Build your cron expression with the Cron Builder.

EventBridge cron syntax (differs from standard cron)

AWS EventBridge uses a 6-field cron (includes year):

cron(minutes hours day-of-month month day-of-week year)
     0-59    0-23     1-31       1-12    1-7        1970-2199

Key differences from standard cron:

  • 6 fields (year added)
  • ? wildcard: use ? in day-of-month OR day-of-week (not both)
  • L = last (e.g., L in day-of-month = last day of month)
  • W = nearest weekday (e.g., 15W = nearest weekday to the 15th)
  • # = nth occurrence (e.g., 2#1 = first Tuesday)
# Daily at 6 PM UTC:
cron(0 18 * * ? *)

# Every Monday at 9 AM UTC:
cron(0 9 ? * MON *)

# First day of each month at midnight:
cron(0 0 1 * ? *)

# Every 15 minutes:
cron(0/15 * * * ? *)

# Weekdays at 8 AM UTC:
cron(0 8 ? * MON-FRI *)

# Last day of every month at 5 AM:
cron(0 5 L * ? *)

Rate expressions (simpler syntax)

rate(value unit)

rate(5 minutes)    # Every 5 minutes
rate(1 hour)       # Hourly
rate(1 day)        # Daily
rate(7 days)       # Weekly

Create a schedule with the AWS CLI

# Create a one-time schedule:
aws scheduler create-schedule \
  --name "my-one-time-job" \
  --schedule-expression "at(2026-06-01T09:00:00)" \
  --schedule-expression-timezone "America/New_York" \
  --flexible-time-window Mode=OFF \
  --target '{
    "Arn": "arn:aws:lambda:us-east-1:123456789012:function:my-function",
    "RoleArn": "arn:aws:iam::123456789012:role/scheduler-role",
    "Input": "{\"key\": \"value\"}"
  }'

# Create a recurring cron schedule:
aws scheduler create-schedule \
  --name "nightly-report" \
  --schedule-expression "cron(0 2 * * ? *)" \
  --schedule-expression-timezone "UTC" \
  --flexible-time-window Mode=OFF \
  --target '{
    "Arn": "arn:aws:lambda:us-east-1:123456789012:function:report-generator",
    "RoleArn": "arn:aws:iam::123456789012:role/scheduler-role"
  }'

AWS SAM / CloudFormation template

# template.yaml
Resources:
  NightlyReportFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs20.x
      Events:
        NightlySchedule:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: "cron(0 2 * * ? *)"
            ScheduleExpressionTimezone: "UTC"
            FlexibleTimeWindow:
              Mode: FLEXIBLE
              MaximumWindowInMinutes: 15
            RetryPolicy:
              MaximumRetryAttempts: 2
              MaximumEventAgeInSeconds: 3600

Terraform: EventBridge Scheduler

resource "aws_scheduler_schedule" "nightly_backup" {
  name       = "nightly-backup"
  group_name = "default"

  flexible_time_window {
    mode = "OFF"
  }

  schedule_expression          = "cron(0 2 * * ? *)"
  schedule_expression_timezone = "UTC"

  target {
    arn      = aws_lambda_function.backup.arn
    role_arn = aws_iam_role.scheduler.arn

    retry_policy {
      maximum_retry_attempts       = 3
      maximum_event_age_in_seconds = 3600
    }

    dead_letter_config {
      arn = aws_sqs_queue.dlq.arn
    }
  }
}

Lambda handler for scheduled events

// Lambda function triggered by EventBridge
export const handler = async (event) => {
  console.log('Scheduled event received:', JSON.stringify(event));
  
  // EventBridge passes the event details:
  // event.source = "aws.scheduler"
  // event['detail-type'] = "Scheduled Event"
  // event.time = ISO timestamp of the scheduled time
  
  try {
    await runScheduledTask();
    return { statusCode: 200, body: 'Success' };
  } catch (error) {
    console.error('Task failed:', error);
    throw error; // Let EventBridge retry based on retry policy
  }
};

Timezone support

EventBridge Scheduler supports IANA timezone names:

aws scheduler create-schedule \
  --schedule-expression "cron(0 9 ? * MON *)" \
  --schedule-expression-timezone "America/New_York" \
  # Runs at 9 AM New York time, correctly handles EST/EDT transitions

This is a major advantage over classic CloudWatch Events which only supports UTC.


Related posts

Related tool

Cron Builder

Build and parse cron expressions with human-readable explanations.

Written by Mian Ali Khalid. Part of the Dev Productivity pillar.