> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Schedule Jobs



## Article: Schedule Jobs

## Article Link: https://dev.wix.com/docs/velo/articles/getting-started/schedule-jobs.md

## Article Content:

# Schedule Jobs

There are many situations in which you want to schedule some code to run at a specific recurring interval. In Velo, you can create jobs and schedule them to run on an hourly, daily, weekly, or monthly basis using the **Job Scheduler**. 

Some common uses of the **Job Scheduler** are to:

-   Import or export data once a day.
-   Delete collection data that is no longer relevant once a week.
-   Send a status report to relevant parties once a month.


## Creating a Scheduled Job

To configure scheduled jobs, start by creating file in the **backend** root named **jobs.config**. The file must contain a JSON object that defines the jobs you want to schedule. You can configure up to twenty jobs.

A job's configuration defines when the job runs and what code it runs. A job can run any backend function defined in your site. Each job is represented by an object in the `jobs` array.

```javascript
// In backend/jobs.config

{
    "jobs": [
        {
            "functionLocation": "/someBackendFile.js", 
            "functionName": "someBackendFunction",
            "description": "Some job description",
            "executionConfig": {
                "dayOfWeek": "Monday",
                "time": "08:00"
            }
        }
    ]
}
```

Each job definition contains the following information:

`functionLocation`: Path to the backend file in which the job function resides.  
`functionName`: Name of the function to run at the scheduled time.  
`description`: Optional job description.  
`executionConfig`: Configuration that defines when the job runs.

There are two mutually exclusive ways to define when the job runs:

-   Using the time property and optional `dayOfWeek` or `dateInMonth` properties.
-   Using a [CRON expression](https://en.wikipedia.org/wiki/Cron#CRON_expression).

A few more things to keep in mind when scheduling jobs are:

-   All times in job configurations are [UTC time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). 
-   If you want to schedule a job to occur more than once a day, you need to use a cron expression. 
-   The shortest interval you can define for a job is one hour. Jobs scheduled more frequently are ignored.
-   You need to publish your site for any changes to your scheduled jobs to take effect.

## Example

Now that you know the rules, let's take a look at some examples of scheduled jobs.

```javascript
// In backend/jobs.config

{
    "jobs": [
        {
            "functionLocation": "/utils.js", 
            "functionName": "sendStatusReport",
            "description": "Send a morning status report",
            "executionConfig": {
                "cronExpression": "0 8 * * MON"
            }
        },  
        {
            "functionLocation": "/utils.js",
            "functionName": "cleanDb",
            "description": "Delete stale items from the DB",
            "executionConfig": {
                "time": "01:00",
                "dateOfMonth": 1
            }
        }
    ]
}
```

Here you can see two scheduled jobs. The first job is scheduled using a cron expression and it sends a status report every Monday morning at 8:00 in the morning UTC time.

```javascript
"executionConfig": {
    "cronExpression": "0 8 * * MON"
}
```

The second job is scheduled using the `time` and `dateOfMonth` properties and it deletes stale items from the site's database at one in the morning UTC time on the first day of every month.

```javascript
"executionConfig": {
    "time": "01:00",
    "dateOfMonth": 1
}
```