add cron example

This commit is contained in:
davidwells 2016-10-11 00:46:56 -07:00
parent 26b1ac9578
commit c3e31ca449
4 changed files with 47 additions and 0 deletions

View 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.

View 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)

View File

@ -0,0 +1,6 @@
'use strict'
module.exports.run = (event, context, callback) => {
const time = new Date()
console.log(`Your cron ran ${time}`)
}

View File

@ -0,0 +1,11 @@
service: cron-example # This is the name of your service
provider:
name: aws # This is the provider were 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)