mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
add cron example
This commit is contained in:
parent
26b1ac9578
commit
c3e31ca449
12
docs/02-providers/aws/examples/cron/README.md
Normal file
12
docs/02-providers/aws/examples/cron/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
<!--
|
||||
title: Serverless Scheduled Cron Example
|
||||
menuText: Scheduled Cron Example
|
||||
description: Create a serverless scheduled cron job
|
||||
layout: Doc
|
||||
-->
|
||||
|
||||
# Schedule Cron
|
||||
|
||||
Create a scheduled task with AWS lambda and automate all teh things!
|
||||
|
||||
For more information on running cron with serverless check out the [Tutorial: Serverless Scheduled Tasks](https://parall.ax/blog/view/3202/tutorial-serverless-scheduled-tasks) by parrallax.
|
||||
18
docs/02-providers/aws/examples/cron/node/README.md
Normal file
18
docs/02-providers/aws/examples/cron/node/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
<!--
|
||||
title: Node Lambda Scheduled Cron Example
|
||||
menuText: Scheduled Cron Example
|
||||
description: Create a serverless scheduled cron job with nodejs and aws lambda
|
||||
layout: Doc
|
||||
-->
|
||||
|
||||
# AWS Lambda Node Cron Function
|
||||
|
||||
This is an example of creating a function that runs on a scheduled cron.
|
||||
|
||||
To see your cron running tail your logs with:
|
||||
|
||||
```bash
|
||||
serverless logs -function cron -tail
|
||||
```
|
||||
|
||||
[Tutorial: Serverless Scheduled Tasks](https://parall.ax/blog/view/3202/tutorial-serverless-scheduled-tasks)
|
||||
6
docs/02-providers/aws/examples/cron/node/handler.js
Normal file
6
docs/02-providers/aws/examples/cron/node/handler.js
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
module.exports.run = (event, context, callback) => {
|
||||
const time = new Date()
|
||||
console.log(`Your cron ran ${time}`)
|
||||
}
|
||||
11
docs/02-providers/aws/examples/cron/node/serverless.yml
Normal file
11
docs/02-providers/aws/examples/cron/node/serverless.yml
Normal file
@ -0,0 +1,11 @@
|
||||
service: cron-example # This is the name of your service
|
||||
provider:
|
||||
name: aws # This is the provider we’re deploying to
|
||||
runtime: nodejs4.3 # You have a choice of Node, Java, or
|
||||
# Python, but you can run native binaries too
|
||||
functions:
|
||||
cron:
|
||||
handler: handler.run # This will require the handler.js file,
|
||||
# and execute the exported run function
|
||||
events:
|
||||
- schedule: rate(1 minute)
|
||||
Loading…
x
Reference in New Issue
Block a user