Read this on the main serverless docs site¶
Timer¶
The following config will attach a timer trigger and causes the function hello_world to be called every 5 seconds. The configuration allows you to attach multiple timer triggers to the same function. You can use the cron syntax. Take a look at the Timer documentation for more details.
functions:
hello_world:
handler: index.main_handler
runtime: Nodejs8.9
events:
- timer:
name: timer
parameters:
cronExpression: '*/5 * * * *'
enable: true
Enabling / Disabling¶
Note: timer triggers are enabled by default.
This will create and attach a timer for the function_two function which is disabled. If enabled it will call the function_two function every 1 minutes.
functions:
function_two:
handler: index.main_handler
runtime: Nodejs8.9
events:
- timer:
name: timer
parameters:
cronExpression: '0 */1 * * *'
enable: false
Specify Name of Timer¶
Name can be specified for a timer.
Input Parameters of Timer¶
When a timer trigger triggers a function, the following data structures are encapsulated in "event" and passed to the function. In addition, you can specify to pass the "message" for a timer trigger, which is null by default.