$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
ServerlessbeginnerNew

Serverless Cron

Share

Set up serverless cron jobs and scheduled functions

Works with OpenClaude

You are a serverless architect. The user wants to set up serverless cron jobs and scheduled functions using AWS Lambda and EventBridge.

What to check first

  • Run aws lambda list-functions to verify AWS Lambda is accessible and configured
  • Check your AWS IAM user has lambda:InvokeFunction, events:PutRule, and events:PutTargets permissions
  • Verify Node.js runtime is available locally with node --version

Steps

  1. Create an IAM execution role for Lambda with trust policy for lambda.amazonaws.com and attach AWSLambdaBasicExecutionRole
  2. Write your Lambda handler function in Node.js that will execute on schedule
  3. Zip the handler code and dependencies into a deployment package
  4. Create the Lambda function using aws lambda create-function with your IAM role ARN
  5. Create an EventBridge rule using aws events put-rule with --schedule-expression in cron format (e.g., cron(0 9 * * ? *) for 9 AM daily)
  6. Add the Lambda function as a target to the EventBridge rule using aws events put-targets
  7. Grant EventBridge permission to invoke your Lambda with aws lambda add-permission
  8. Test the rule by manually triggering with aws lambda invoke or wait for the scheduled time

Code

// handler.js - Lambda function that runs on schedule
exports.handler = async (event) => {
  console.log('Scheduled job triggered at:', new Date().toISOString());
  console.log('Event source:', event.source);
  
  // Your cron job logic here
  try {
    // Example: cleanup task
    const result = await performScheduledTask();
    
    return {
      statusCode: 200,
      body: JSON.stringify({
        message: 'Cron job completed successfully',
        data: result,
        timestamp: new Date().toISOString()
      })
    };
  } catch (error) {
    console.error('Error in scheduled job:', error);
    throw error;
  }
};

async function performScheduledTask() {
  // Simulate async work: fetch data, process, cleanup, etc.
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({ itemsProcessed: 42 });
    }, 1000);
  });
}
#!/bin/bash
# deploy-cron.sh - Complete deployment script

# 1. Create execution role
ROLE_ARN=$(aws iam create-role \
  --role-name lambda-cron-role \
  --assume-role-policy-document '{
    "Version": "2012-10-17",
    "Statement": [{
      "Effect": "Allow",
      "Principal": {"Service": "lambda.amazonaws.com"},
      "Action": "sts:AssumeRole"
    }]
  }'

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryServerless
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
serverlesscronscheduling

Install command:

curl -o ~/.claude/skills/serverless-cron.md https://claude-skills-hub.vercel.app/skills/serverless/serverless-cron.md

Related Serverless Skills

Other Claude Code skills in the same category — free to download.

Want a Serverless skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.