---
title: Create a nightly maintenance job
slug: configured-commerce/docs/create-a-nightly-maintenance-job
docTags: 
createdAt: 2026-08-13T10:46:21.000Z
---

Optimizely Configured Commerce contains a nightly maintenance job that cleans up abandoned shopping cart records, maintains the application log, deletes orphaned custom properties, removes obsolete scheduled task records, and analyzes query plans to identify fast queries because a table is small. You should schedule the job to run each night during non-peak hours within your SQL server or by creating a Nightly Maintenance Scheduled Task within the Admin Console. Four finger tabs exist for creating an integration job: **Details**, **Steps**, **Parameters**, and **History**.

## Details finger tab

1. Click **Add Job Definition**.
2. Populate the following fields as shown:
   - **Job Name** – Something like *Nightly Maintenance Job*
   - **Job Type** – Execution
   - **Connection** – Internal. Go to **Admin Console** > **Administration** > **Connections** to define this field.
   - **Preprocessor** – None
   - **Integration Processor** – None
   - **Post Processor** – ExecuteStoredProcedure
3. Go to **Notifications** and enter the following fields:
   - **Notification Email List** – Enter any email address that should receive notifications, separated by commas.
   - **Notify Condition** – Choose the condition to notify by email, such as **Completion**.
   - (Optional) **Email Template** – Choose an email template the email should follow.
   - (Optional) **Linked Job** – Choose a job that links to this one.
   - **Link Condition** – Choose a condition that triggers the linked job, such as **Success Only**.
4. Populate the following fields for **Run Options**:
   - **Max Errors Before Failing** – The number of errors allowed during processing before the job terminates.
   - **Max Warnings Before Failing** – The number of warnings allowed during processing before the job terminates.
   - **Max Deactivation %** – The number of products deactivated by the integration job before it triggers a failure. This protects from misconfigured or incorrect integration job definitions.
   - (Optional) **Processing Batch Size** – The size of the batch the job should process.
5. Go to **Recurrence** and populate the following fields:
   - **Run as a Recurring Job** – Whether to run this job as a recurring job
   - **Start Date/Time** – Date and time for when the first job starts
   - **End Date/Time** – Date and time for when the last job ends
   - **Repeat Every** – The number of recurrences, such as None, Minutes, Hours, Days, or Months. This setting does not adjust for Daylight Savings Time.

## Steps finger tab

Nothing is required in the **Steps** finger tab.

## Parameters finger tab

1. Go to **Parameters**.
2. Click **Add Job Definition Parameter**.
3. Enter the name **NightlyMaintenance** as the **default value** for **Stored Procedure**. This directly correlates to the name of the stored procedure that is deployed with the platform.
4. Select the **Value Type** of **String**.
5. Enter the **Default Value.**
6. Enter the **Prompt** as the **Stored Procedure Name**.
7. Click **Save.**
8. Click **Back** or use the breadcrumb trail to click **Nightly Maintenance Job**. The **Parameters** finger tab displays the created parameter.

## History finger tab

The **History** finger tab lists previously run jobs and their respective metadata.

## Manually running the job

1. Click **More Options** and select **Schedule Job**.
2. Choose the **Date/Time**.
3. Decide if it should run as a **Real-Time Job** or not.
4. Click **Schedule Job**.

:::hint{type="info"}
**Note**

In recent releases of Configured Commerce, the nightly maintenance job includes a step that attempts to reactivate untrusted foreign keys within the database. Some older databases have these, which can lead to unexpected results from queries. If reactivating the foreign key is unsuccessful, a warning is logged indicating the problem, indicating that bad data is present in the database. When the bad data is cleaned, the next run of nightly maintenance should be clear. 
:::
