Schedule Recurring Jobs

You can schedule recurring jobs to run on any backend function at specified intervals.

To schedule recurring jobs on your site:

Step 1 | Add a backend function

Add an exported function to the backend that you want to run with a scheduled job. The function can be in any backend .js, .web.js, or .jsw file.

Step 2 | Add the jobs.config file in the backend

The way that you add the jobs.config file depends on which IDE you're using.

To add the jobs.config file:

Editor

  1. Go to the Public & Backend section of the code panel.
  2. Hover over Backend, click the plus icon , and select Add scheduled jobs.

A jobs.config file opens in the code editor. The file includes a sample JSON object for defining scheduled jobs.

Wix IDE or your local IDE

  1. Add a jobs.config file to the src/backend folder.
  2. Copy the sample JSON object and paste it into the file.

Step 3 | Edit the JSON object to define the scheduled job

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 following properties:

  • functionLocation
  • functionName
  • description (optional)
  • executionConfig

Use the jobs JSON object reference for additional details on each property.

Tip: 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 8:00 AM UTC time:

Copy

Schedule multiple jobs

Schedule multiple jobs in the jobs.config file by adding additional objects to the jobs array.

Copy

Step 4 | Publish your site

You must publish your site to save changes to your scheduled jobs.

See also

Was this helpful?
Yes
No