You can create jobs to run any backend function and schedule them to run at specified, recurring intervals.
It's important to note the following before starting to code:
The first step is to add a backend function that you want to run with a scheduled job. The function can be in any backend .js, .jsw or .web.js file.
Note: Make sure you export the function that you want the job scheduler to run.
The jobs.config file contains a JSON object which defines all the scheduled jobs for your site. Each object in the jobs
array contains the functionLocation
, functionName
, description
, and executionConfig
. Use the jobs JSON object reference for additional details on each field.
To simplify the process of building your jobs.config file, you can use this third-party Jobs Config tool. It allows you to enter the details of your jobs and builds the jobs object for you. The tool also includes a validator that can check your existing jobs.config file for errors.
Here is an example of a JSON object configured to send a status report every Monday morning at 8am UTC time:
1
Schedule multiple jobs in your jobs.config file by adding additional objects to the jobs
array.
1
You must publish your site to save changes to your scheduled jobs.
You can monitor the progress of a scheduled job with Wix Logs. If there is an error with the job syntax, it will display in Wix Logs when you publish your site. Additionally, if the function used in the job contains a console.log()
then it will log to Wix Logs when it is called.
Connect Wix Logs to Google Cloud Logs, or another monitoring tool, so that you don't need to monitor the logs live as the jobs are triggered.