AWS Lambda logo

How to schedule a periodic job on AWS Lambda with EventBridge Scheduler

AWS Lambda has no scheduler of its own. To run a function every night or every 15 minutes, you create a schedule in Amazon EventBridge Scheduler that points at the function, and Scheduler invokes it at every matching time. The Lambda console sets that up in a minute. This guide also covers the CLI, AWS SAM and Terraform, the six-field cron syntax, time zones, and what causes trouble later: retries, duplicate runs and overlapping runs.

Everything below was checked against the AWS documentation in November 2026. AWS now calls standard Lambda functions Event Functions in its docs and console; only the name changed.

Key takeaways

  • Use EventBridge Scheduler. AWS marks the older scheduled rules (from the CloudWatch Events days) as a legacy feature, and they only run in UTC.
  • In the Lambda console: Add trigger → Scheduler, then a name, a cron or rate expression and Create new role for this schedule.
  • AWS cron has six fields, including the year, and one of the two day fields must be ?. cron(0 7 * * ? *) is 07:00 every day.
  • Scheduler invokes the function asynchronously, so there are two retry layers and the same run can arrive twice. Make the handler idempotent.
  • A run stops after 15 minutes. Reserved concurrency of 1 keeps runs from overlapping.

How a scheduled Lambda run works

Three pieces are involved: the schedule (an expression, a time zone and a JSON payload), an IAM execution role that Scheduler assumes, and the function. At each matching time, Scheduler assumes the role and calls Lambda's Invoke API asynchronously. Lambda queues the event and answers straight away, and for Scheduler the run is delivered.

Diagram: a schedule with a cron expression, a time zone and a payload is evaluated by EventBridge Scheduler, which assumes the execution role and invokes Lambda asynchronously. Lambda accepts the event, queues it and runs the handler. Hand-off failures fall under Scheduler's retry policy and dead-letter queue; function errors fall under Lambda's asynchronous retries and on-failure destination.
Scheduler only hands the event to Lambda. What happens after that is Lambda's job, with its own retries.

That hand-off splits failure handling in two. If Scheduler can't deliver the event (the role lacks permission, the function is gone), Scheduler's retry policy and dead-letter queue apply. If the function throws an error or times out, Lambda's own retry settings apply, and Scheduler never hears about it. The retries section shows where to set each.

The function receives the schedule's JSON payload as its event and nothing else: no schedule name and no timestamp, unlike an EventBridge rule. If the handler needs to know which run it is, add a placeholder to the payload, as shown below.

Create the schedule in the Lambda console

The console creates the schedule and its execution role in one go. Work in the Region where the function is deployed.

  1. Open the Lambda console, go to the Event Functions page and choose your function.
  2. In the Function overview pane, choose Add trigger.
  3. From the trigger source list, choose Scheduler. Searching for schedule or cron finds it too.
  4. Enter a Schedule name and keep the default Schedule group unless you organise schedules in groups.
  5. For Schedule type, choose Recurring schedule and enter a cron or rate expression, such as cron(0 7 * * ? *). One-time schedule runs the function once at a date and time.
  6. Optionally enter a JSON payload, such as {"mode": "full"}. Without one, the function gets an empty event.
  7. For the execution role, choose Create new role for this schedule and enter a Role name. Scheduler creates the role with the permission it needs to invoke the function.
  8. Choose Add.

The schedule then appears in the function's Triggers section under Scheduler, along with schedules created elsewhere (the Scheduler console, the CLI, CloudFormation, SAM or the CDK). For a flexible time window, a retry policy or a dead-letter queue, edit the schedule in the EventBridge Scheduler console, whose Timeframe section also shows the time zone. A 15-minute flexible window lets an hourly run start anywhere in the 15 minutes after the hour; leave it Off for jobs that should start on the minute.

Write the schedule expression

The same field takes three kinds of expression:

TypeExampleRuns
Croncron(0 7 * * ? *)At 07:00 every day, in the schedule's time zone
Raterate(15 minutes)Every 15 minutes, counted from the start date
One-timeat(2026-12-01T09:00:00)Once, at that time in the schedule's time zone

Cron: six fields, and the rules that differ from Linux

FieldValuesWildcards
Minutes0–59, - * /
Hours0–23, - * /
Day-of-month1–31, - * ? / L W
Month1–12 or JAN–DEC, - * /
Day-of-week1–7 or SUN–SAT, - * ? L #
Year1970–2199, - * /
  • All six fields are required. A crontab line like 0 7 * * * isn't valid here.
  • One day field must be ?. Day-of-month and day-of-week can't both be set, or both be *: cron(0 2 ? * MON-FRI *) is 02:00 on weekdays, cron(0 2 1 * ? *) is 02:00 on the 1st.
  • Day-of-week 1 is Sunday, where Linux cron uses 1 for Monday. Names such as MON-FRI avoid the off-by-one.
  • Extras: L for the last day of the month or week, 3W for the weekday nearest the 3rd, 3#2 for the second Tuesday.

The Unix, Quartz and AWS cron converter rewrites a Linux expression in this format.

Rate and one-time expressions

A rate takes minute, minutes, hour, hours, day or days. Use the singular for 1 and the plural above it (rate(1 hour), rate(5 minutes)); legacy rules insist on that. A rate has no clock anchor: it starts at the schedule's start date, or immediately, so rate(1 day) created at 15:42 runs at about 15:42 daily. If the time of day matters, use cron.

A completed one-time schedule still counts against the Region's schedule quota (10,000,000 by default). Set Action after schedule completion to DELETE and it removes itself; the default, NONE, keeps it.

Time zones and daylight saving time

Cron and one-time schedules are evaluated in the schedule's time zone, an IANA name such as Europe/Berlin. Without one they run in UTC, so cron(0 7 * * ? *) meant for Berlin fires at 08:00 or 09:00 local time.

With a time zone set, Scheduler handles daylight saving time itself. In the AWS example, cron(30 2 * * ? *) in America/Los_Angeles:

  • Spring forward: clocks jump from 01:59 to 03:00, so 02:30 doesn't exist and that day's run is skipped.
  • Fall back: 02:30 happens twice. Scheduler skips the first and runs once, at the second.

If a job must run every day, keep it out of the hour your clocks change. Rate schedules ignore all this: rate(1 day) is 24 hours, even on a 23- or 25-hour day. More in the cron, time zones and daylight saving time guide.

Legacy EventBridge rules always run in UTC. A rule for 07:00 in Berlin needs cron(0 5 * * ? *) in summer and cron(0 6 * * ? *) in winter, which is reason enough to move it.

Create the schedule with the AWS CLI

The CLI, the SDKs and CloudFormation don't create the execution role for you, so that comes first. Save the trust policy as scheduler-trust.json. The Condition limits the role to schedules in your own account and schedule group, which AWS recommends as protection against the confused-deputy problem:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": { "Service": "scheduler.amazonaws.com" },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "aws:SourceAccount": "123456789012",
          "aws:SourceArn": "arn:aws:scheduler:eu-central-1:123456789012:schedule-group/default"
        }
      }
    }
  ]
}

Then the permission, saved as invoke-cleanup.json. The AWS example allows every function ("Resource": "*"); scoped to one function, a schedule that borrows this role can't call anything else. The second ARN covers versions and aliases:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "lambda:InvokeFunction",
      "Resource": [
        "arn:aws:lambda:eu-central-1:123456789012:function:nightly-cleanup",
        "arn:aws:lambda:eu-central-1:123456789012:function:nightly-cleanup:*"
      ]
    }
  ]
}
aws iam create-role \
  --role-name nightly-cleanup-scheduler \
  --assume-role-policy-document file://scheduler-trust.json

aws iam put-role-policy \
  --role-name nightly-cleanup-scheduler \
  --policy-name invoke-nightly-cleanup \
  --policy-document file://invoke-cleanup.json

Now the schedule. --flexible-time-window is required even when you don't want one, and the target's Input must be well-formed JSON for a Lambda target:

aws scheduler create-schedule \
  --name nightly-cleanup \
  --schedule-expression "cron(0 7 * * ? *)" \
  --schedule-expression-timezone "Europe/Berlin" \
  --flexible-time-window '{"Mode": "OFF"}' \
  --target '{
    "Arn": "arn:aws:lambda:eu-central-1:123456789012:function:nightly-cleanup",
    "RoleArn": "arn:aws:iam::123456789012:role/nightly-cleanup-scheduler",
    "Input": "{\"mode\": \"full\", \"scheduled_time\": \"<aws.scheduler.scheduled-time>\"}",
    "RetryPolicy": {"MaximumRetryAttempts": 3, "MaximumEventAgeInSeconds": 3600}
  }'

aws scheduler get-schedule --name nightly-cleanup shows the stored settings, but not the next run time.

Define the schedule in AWS SAM or Terraform

In AWS SAM, a ScheduleV2 event on the function generates an AWS::Scheduler::Schedule. The older Schedule type generates a legacy rule instead. If you leave out RoleArn, SAM also creates the execution role, and without a FlexibleTimeWindow it sets the window to OFF.

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  NightlyCleanup:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: src/
      Handler: app.handler
      Runtime: python3.14
      Timeout: 300
      ReservedConcurrentExecutions: 1
      Events:
        Nightly:
          Type: ScheduleV2
          Properties:
            ScheduleExpression: "cron(0 7 * * ? *)"
            ScheduleExpressionTimezone: Europe/Berlin
            Input: '{"mode": "full", "scheduled_time": "<aws.scheduler.scheduled-time>"}'
            RetryPolicy:
              MaximumRetryAttempts: 3
              MaximumEventAgeInSeconds: 3600

In Terraform, the resource is aws_scheduler_schedule, and the role is yours to define. flexible_time_window, schedule_expression and a target with arn and role_arn are required:

data "aws_caller_identity" "current" {}

resource "aws_iam_role" "scheduler" {
  name = "nightly-cleanup-scheduler"
  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow"
      Principal = { Service = "scheduler.amazonaws.com" }
      Action    = "sts:AssumeRole"
      Condition = {
        StringEquals = { "aws:SourceAccount" = data.aws_caller_identity.current.account_id }
      }
    }]
  })
}

resource "aws_iam_role_policy" "invoke" {
  name = "invoke-nightly-cleanup"
  role = aws_iam_role.scheduler.id
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect   = "Allow"
      Action   = "lambda:InvokeFunction"
      Resource = [aws_lambda_function.cleanup.arn, "${aws_lambda_function.cleanup.arn}:*"]
    }]
  })
}

resource "aws_scheduler_schedule" "nightly_cleanup" {
  name                         = "nightly-cleanup"
  schedule_expression          = "cron(0 7 * * ? *)"
  schedule_expression_timezone = "Europe/Berlin"

  flexible_time_window {
    mode = "OFF"
  }

  target {
    arn      = aws_lambda_function.cleanup.arn
    role_arn = aws_iam_role.scheduler.arn
    input    = "{\"mode\": \"full\", \"scheduled_time\": \"<aws.scheduler.scheduled-time>\"}"

    retry_policy {
      maximum_retry_attempts       = 3
      maximum_event_age_in_seconds = 3600
    }
  }
}

The input is a literal string on purpose: Terraform's jsonencode() escapes < and > as \u003c and \u003e, and the placeholder should reach Scheduler exactly as written.

Retries, failures and duplicate runs

A scheduled run has two separate safety nets. Most surprises come from configuring one and expecting the other.

LayerCatchesDefaultChange it in
EventBridge SchedulerThe event never reaches Lambda: the role can't invoke the function, or the function was deleted185 retries within 24 hours; no dead-letter queueThe schedule's retry policy (0–185 retries, 60 seconds to 24 hours) and dead-letter queue (a standard SQS queue)
Lambda asynchronous invocationThe function throws an error or times out; throttled runs2 retries, 1 and 2 minutes apart; throttled events kept for up to 6 hoursConfiguration → Asynchronous invocation: Retry attempts (0–2), Maximum age of event (60 seconds to 6 hours), on-failure destination

So a function that fails three times in a row never shows up in Scheduler's metrics or dead-letter queue. Give the function an on-failure destination (an SQS queue, SNS topic, S3 bucket, another function or an event bus) so failed runs land somewhere you look. A dead-letter queue on the schedule also needs sqs:SendMessage in its execution role.

aws lambda put-function-event-invoke-config \
  --function-name nightly-cleanup \
  --maximum-retry-attempts 1 \
  --destination-config '{"OnFailure": {"Destination": "arn:aws:sqs:eu-central-1:123456789012:nightly-cleanup-failures"}}'

This command replaces any existing settings; update-function-event-invoke-config changes only the options you pass.

Make the handler safe to run twice

Scheduler promises at-least-once delivery, and Lambda's queue can hand the same event to a function more than once even when nothing failed. Add a function retry, and one scheduled time can reach your handler two or three times. Deleting rows by key doesn't mind; sending an invoice does.

Scheduler fills in four placeholders in the payload: <aws.scheduler.schedule-arn>, <aws.scheduler.scheduled-time>, <aws.scheduler.execution-id> and <aws.scheduler.attempt-number>. The scheduled time is the right key for a run, because the execution ID changes with every attempt. The CLI, SAM and Terraform examples above pass it as scheduled_time, and the handler claims the run with a conditional write before doing any work:

import os

import boto3
from botocore.exceptions import ClientError

runs = boto3.resource("dynamodb").Table(os.environ["RUNS_TABLE"])


def cleanup(mode):
    ...  # the actual job: delete old rows, build a report, call an API


def handler(event, context):
    run_id = "nightly-cleanup#" + event["scheduled_time"]
    try:
        # Claim the run. This fails if another delivery claimed it first.
        runs.put_item(
            Item={"run_id": run_id},
            ConditionExpression="attribute_not_exists(run_id)",
        )
    except ClientError as err:
        if err.response["Error"]["Code"] == "ConditionalCheckFailedException":
            print(f"{run_id} already handled, skipping")
            return {"skipped": run_id}
        raise

    try:
        cleanup(event.get("mode", "full"))
    except Exception:
        runs.delete_item(Key={"run_id": run_id})  # let a retry try again
        raise
    return {"done": run_id}

The table needs a string partition key named run_id, and the function's own role needs dynamodb:PutItem and dynamodb:DeleteItem on it. Don't confuse that role with the scheduler's execution role, which only needs lambda:InvokeFunction.

Keep runs from overlapping

If a run can outlast the gap between two runs, Lambda simply starts a second copy. For jobs that must not run in parallel, set reserved concurrency to 1 under Configuration → Concurrency → Edit → Reserve concurrency, or from the CLI:

aws lambda put-function-concurrency \
  --function-name nightly-cleanup \
  --reserved-concurrent-executions 1

Reserved concurrency costs nothing extra. Because the call is asynchronous, the second run isn't lost: Lambda throttles it, keeps the event and retries with a growing back-off (at most 5 minutes apart) until it can run or the maximum event age runs out.

Timeline: a schedule fires every 10 minutes and each run takes 12 minutes. Without reserved concurrency the runs overlap by two minutes each time. With reserved concurrency set to 1, each new run waits in Lambda's queue until the previous run ends, and the wait grows with every run.
Reserved concurrency turns overlap into delay. If runs are always longer than the interval, the delay keeps growing.

If a late run is worse than a skipped one, lower the function's Maximum age of event (down to 60 seconds) so a throttled run expires to the on-failure destination. The limit applies to every caller: a manual test during a scheduled run is throttled too.

Jobs that run longer than 15 minutes

The function timeout defaults to 3 seconds and goes up to 900 seconds (15 minutes), under Configuration → General configuration. Set it well above the job's real duration. A job that may need longer needs a different shape:

  • Batch it. Each run processes a slice and records where it stopped.
  • Schedule a Step Functions state machine. It's a templated target like Lambda: use the state machine ARN and give the role states:StartExecution.
  • Use Lambda durable functions, which checkpoint progress and can carry one execution for up to a year.
  • Run a container: Scheduler can start an Amazon ECS task directly. Functions on Lambda Managed Instances also allow 90 minutes for asynchronous invocations.

Which AWS service fits a given job is covered in our overview of periodic jobs on AWS.

Test the schedule and confirm it ran

Test the function first, with the payload the schedule will send. A synchronous invoke writes the handler's return value to response.json:

aws lambda invoke \
  --function-name nightly-cleanup \
  --cli-binary-format raw-in-base64-out \
  --payload '{"mode": "full", "scheduled_time": "2026-11-17T07:00:00Z"}' \
  response.json

Then test the schedule with a throwaway one-time schedule a few minutes ahead. It deletes itself after firing and leaves the real one untouched:

aws scheduler create-schedule \
  --name nightly-cleanup-smoke-test \
  --schedule-expression "at(2026-11-17T14:05:00)" \
  --schedule-expression-timezone "Europe/Berlin" \
  --action-after-completion DELETE \
  --flexible-time-window '{"Mode": "OFF"}' \
  --target '{
    "Arn": "arn:aws:lambda:eu-central-1:123456789012:function:nightly-cleanup",
    "RoleArn": "arn:aws:iam::123456789012:role/nightly-cleanup-scheduler",
    "Input": "{\"mode\": \"test\", \"scheduled_time\": \"<aws.scheduler.scheduled-time>\"}"
  }'

To confirm a run, look in two places:

  • The function's log group, by default /aws/lambda/nightly-cleanup. In the default text log format, each run shows a START line at the expected minute, then END and a REPORT line with the duration.
  • Scheduler's metrics in the AWS/Scheduler namespace: InvocationAttemptCount (Scheduler tried), TargetErrorCount (Lambda refused the call) and InvocationDroppedCount (Scheduler gave up). AWS delivers them on a best-effort basis, so read them as a trend.

A missing run usually means the schedule is DISABLED, its start date is still ahead, or it has no time zone and ran at the UTC time instead. A rising TargetErrorCount means the role names the wrong function or Region, or the function was renamed. A START line with no result means the function failed: check its Errors and Throttles metrics. To catch a schedule that quietly stops later, see monitoring cron jobs.

Already using an EventBridge rule?

Scheduled rules still work. The EventBridge console lists them under Scheduler → Scheduled rule (legacy), and AWS recommends Scheduler for anything new. A rule runs only in UTC, lives only on the default event bus, has no one-time schedules, and sends a full EventBridge event unless you set constant JSON input. It gets permission through an execution role or a resource-based policy on the function:

aws lambda add-permission \
  --statement-id InvokeLambdaFunction \
  --action lambda:InvokeFunction \
  --principal events.amazonaws.com \
  --function-name nightly-cleanup \
  --source-arn arn:aws:events:eu-central-1:123456789012:rule/nightly-cleanup

To move a job, create the schedule, watch it run once, then delete the rule and this permission so the job doesn't run twice.

Calling the function over HTTPS instead

If you'd rather not manage scheduler IAM roles, or you already schedule other HTTP jobs in one place, a function URL turns the function into an HTTPS endpoint any scheduler can call. Here is that setup with Cronit:

  1. In the function, open Configuration → Function URL → Create function URL, choose Auth type NONE and save. The console adds the resource-based policy that allows public calls. The URL looks like https://<url-id>.lambda-url.<region>.on.aws.
  2. Store a long random secret in the function's environment as CRON_SECRET and reject every request that doesn't carry it.
  3. Set reserved concurrency to 1. A call that arrives while a run is still going then gets HTTP 429 instead of starting a second copy.
  4. In Cronit, create a job with method POST, the function URL, a header X-Cron-Secret with the secret, the schedule 0 7 * * * and the time zone Europe/Berlin. Send the test request before saving and expect a 200; afterwards every run appears in the job's execution log with its status.
import hmac
import os


def cleanup(mode):
    ...  # the actual job


def handler(event, context):
    headers = {k.lower(): v for k, v in (event.get("headers") or {}).items()}
    supplied = headers.get("x-cron-secret", "").encode()
    if not hmac.compare_digest(supplied, os.environ["CRON_SECRET"].encode()):
        return {"statusCode": 401, "body": "unauthorized"}
    cleanup("full")
    return {"statusCode": 200, "body": "done"}

This is a trade, not an upgrade. What you give up:

  • IAM. With auth type NONE, anyone with the URL can call it; the secret header is the only gate. Every request runs the function, rejected ones included. Keep the secret out of code and logs, and replace it if it leaks.
  • Asynchronous delivery. The HTTP request stays open until the handler returns, so answer quickly and hand long work off.
  • AWS's retries and dead-letter queue. Cronit doesn't retry a failed call: the next scheduled run is the next attempt, and a job that keeps failing switches itself off.

Plans and monthly run allowances are in the pricing section.

What it costs, and how to clean up

Prices as of November 2026, from the AWS pricing pages:

  • EventBridge Scheduler: 14 million invocations per month free, then $1.00 per million. A nightly job uses about 30 invocations a month; rate(1 minute) uses about 43,800.
  • Lambda: 1 million requests and 400,000 GB-seconds per month free, then $0.20 per million requests plus duration, from $0.0000166667 per GB-second on x86 in US East (N. Virginia).

A 512 MB function running 30 seconds every 15 minutes comes to about 2,900 runs and 44,000 GB-seconds a month, inside both free tiers. CloudWatch Logs storage is billed separately, so set a retention period on the log group.

When a job is retired, delete the schedule first: it's a separate resource, and one pointing at a deleted function keeps firing and failing.

aws scheduler delete-schedule --name nightly-cleanup

aws iam delete-role-policy \
  --role-name nightly-cleanup-scheduler \
  --policy-name invoke-nightly-cleanup

aws iam delete-role --role-name nightly-cleanup-scheduler

FAQ

How precise is the start time of a scheduled Lambda run?
To the minute, not the second. With the flexible time window off, a schedule set for 07:00 invokes its target somewhere between 07:00:00 and 07:00:59. Don't write code that assumes it starts in the first second of the minute.
Can one Lambda function serve several schedules?
Yes. Create one schedule per cadence and give each its own payload, for example {"mode": "full"} every night and {"mode": "delta"} every hour, then branch on event["mode"] in the handler. The schedules can share one execution role.
How do I pause a scheduled Lambda job without deleting it?
Switch off Enable schedule in the EventBridge Scheduler console. With the CLI, be careful: update-schedule replaces the whole schedule, and every optional field you leave out (time zone, payload, retry policy) goes back to its default. Run get-schedule first and pass all values again with --state DISABLED.
Can a scheduled Lambda function run more often than once a minute?
No. Schedule expressions have no seconds field, and one minute is the shortest interval. For work every 20 seconds, schedule the function every minute and loop three times inside one invocation, sleeping between passes. You pay for the time the function spends waiting.

Run online cronjobs without server setup

Plan, schedule and run periodic tasks and scripts, from your browser with the first online cronjob platform.

Try for free