#Schedules
Schedules are used to define actions that should happen at specific times or regular intervals. For example, an Addon may define a Schedule to regularly import data from an external source, then Build and Deploy the site to Production.
#Actions
Each Schedule has a specific action that it performs.
Action | Description |
---|---|
Deploy to Production | Builds and Deploys the Site to Production |
Run Script | Runs a custom script you provide (see below) |
Addon Event | Sends an Event to an Addon to be handled by that Addon |
#General Options
You can disable any Schedule to prevent it from running automatically without having to delete it.
You can also specify whether a Schedule "allows overlap". For example, if a Schedule generally takes 20 minutes to complete, but runs every 10 minutes, the Schedule System will not try to run the Schedule again while it's already running unless you specifically allow overlapping.
Script Schedules and Addon Event Schedules have a Timeout setting. This is the amount of time the Schedule System will allow the Schedule to run before considering it the run a failure.
#Times
You can define whether the Schedule should run at specific times (like the 1st of every month) or should run at a specific interval (like every 90 minutes).
The time you specify is relative to the selected timezone. For example, you may wish for one of your Schedules to run at 12:30 PM in Central Time. It's easier to enter 12:30 PM and then select Central Time than it is to mentally calculate what time that would be relative to UTC.
To specify when a Schedule should run, enter values for Minute, Hour, etc. The values you enter represent what that unit should be when the Schedule should run. For example, if you set Minute to 30
, the Schedule will run at 12:30 AM, 1:30 AM, and so on. Blank values can be anything.
The following values are valid for Specific Time Schedules:
Unit | Values | Example |
---|---|---|
Minute | 0-59 | 0 , 30 , 0, 30 , 30-45 |
Hour | 0-23 | 0 , 12 , 7-19 |
Date | 1-31 | 1 , 15 , 15-20 |
Month | 1-12, Jan-Dec, January-December | 1 , jan, apr, jul, oct , oct-dec |
Year | 2020+ | 2024 , 2024-2028 |
Day Of Week | 1-7, Sun-Sat, Sunday-Saturday | 4 , wed , sat, sun , mon-fri |
Any of the values entered support ,
and -
, so you could for example write 0, 15, 30, 45
for Minutes, or mon-fri
for Day Of Week. All times are case-insensitive and support abbreviations.
#Logs
You can view logs for the last 10 runs of any Schedule. Any error that occurred or output from the Schedule will be recorded and can be viewed. When the Logging System is completed, you will be able to view logs further back than the last 10 runs.
#Script Schedules
Script Schedules run a specific script you have written. This is most useful for contacting some external API or microservice you have written that the Site communicates with. For example, you could have a Component that makes live calls to get weather data to show on the website. You can then set a Schedule that tells the weather service you wrote to refresh its data once per hour.
console.log('Refreshing weather data at weather.example.com...')
await request.post('https://api.weather.example.com/refresh')
console.log('Refreshed successfully!')
You have access to a request
object which allows you to make external requests over HTTP. This object is currently just an axios object (see Axios)). You are able to use all of Axios' options such as adding Authorization headers to your requests.
Also, anything you log using console.log
will be recorded in the Schedule's log.
In the future, you will be able to use data from within Collections and Site statistics such as Page count in your Schedule Scripts to send data to external services, generate reports, etc.
#Addon Event Schedules
Addons are able to provide their own Schedules which trigger special functionality provided by the Addon. While Addons provide the functionality, you can define the time at which these Schedules run or disable them altogether.
You can also set an Addon's Schedule to Deploy to Production to Production after the Schedule completes. This is especially useful for Schedules that import new data on a regular basis. Note that the Deploy to Production will occur after all newly imported Media has finished processing which does not count toward the Schedule's Timeout. For more information, see Addon Schedule Development.