You can trigger the functions by using a scheduled event. This will execute the function according to the cron expressions you specify.
You can use cron
syntax.
The following example is a function configuration in the serverless.yml file that are scheduled to trigger the function crawl every day at 6:30 PM.
functions:
crawl:
handler: handler.crawl
cron: # Setup scheduled trigger with cron expression
active: true
value: '30 18 * * *'
You also have the option to set your functions active status as either true or false
Note schedule
events active status are set to true by default
This example will create and attach a schedule event for the function crawl
which is active status is set to false
. If the status is changed to true the crawl
function will be called every Monday at 6:00 PM.
functions:
crawl:
handler: handler.crawl
cron: # Setup scheduled trigger with cron expression
active: false
value: '* 18 * * 1'
Note When creating a cron
trigger the value
is the crontab expression. For help on crontab check out the documentation
Product