---
title: Create a nightly maintenance job
slug: configured-commerce/sdk/creating-a-nightly-maintenance-job
docTags: 
createdAt: 2026-08-05T19:24:05.151Z
---

The Optimizely \{user\["product-name"]} database contains a Nightly Maintenance stored procedure which cleans up abandoned shopping cart records, maintains the application log, and removes obsolete scheduled task records. The Nightly Maintenance stored procedure should be scheduled to run each night during non-peak hours. This can be accomplished within your SQL server or by creating a Nightly Maintenance Scheduled Task within the \{user\["product-name"]} Admin Console. There are four finger tabs related to the creation of an Integration Job: **Details**, **Steps**, **Parameters**, and **History**.

Go to **Admin Console** > **Administration** > **Jobs** > **Job Definitions** > **Details** finger tab.

## Details finger tab

1. Click **Add Job Definition**.
2. Populate the following fields as shown:

| Field Name            | Field Properties                            |
| --------------------- | ------------------------------------------- |
| Job Name              | Something akin to "Nightly Maintenance Job" |
| Job Type              | Execution                                   |
| Connection\*          | Internal                                    |
| Preprocessor          | None                                        |
| Integration Processor | None                                        |
| Post Processor        | ExecuteStoredProcedure                      |

\*The **Connection** is defined by the Connection created in the **Connections** page: **Admin Console** > **Administration** > **Jobs** > **Connections**. It is here that type of connection is defined:

:::Paragraph{listStyleType="disc" indent="2"}
SqlServer
:::

:::Paragraph{listStyleType="disc" indent="2"}
WebService
:::

:::Paragraph{listStyleType="disc" indent="2"}
OleDb
:::

:::Paragraph{listStyleType="disc" indent="2"}
Odbc
:::

:::Paragraph{listStyleType="disc" indent="2"}
SapDotNetConnector
:::

:::Paragraph{listStyleType="disc" indent="2"}
XmlFile
:::

:::Paragraph{listStyleType="disc" indent="2"}
FlatFile
:::

:::Paragraph{listStyleType="disc" indent="2"}
Internal
:::

3. Scroll down to the **Notifications** section, populate the following fields

| Field Name                    | Field Properties                                                                                                                               |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| Notification Email List       | Enter in the email addresses of the users to be notified when the **Notify Condition** is met. These addresses are separated with a semicolon. |
| Notify Condition              | Choose the condition for which the notification emails will be triggered.                                                                      |
| Email Template and Linked Job | Optional fields. The linked job is triggered if the **Link Condition** is met.                                                                 |
| Link Condition                | Select a condition from the list. If there is no **Linked Job**, the **Link Condition** has no bearing.                                        |

4. Scroll down to the Run Options section, populate the following fields:

| Fields                      | Field Properties                                                                                                                                                        |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Max Errors Before Failing   | The number of errors allowed to occur during processed before the job terminates.                                                                                       |
| Max Warnings Before Failing | The number of warnings allowed to occur during processed before the job terminates.                                                                                     |
| Max Deactivation %          | The number of products deactivated by the integration job before it triggers a failure. This is to protect from misconfigured or incorrect integration job definitions. |

5. Scroll down to the Recurrence section, populate the following fields:

| Fields                 | Field Properties                                                                                      |
| ---------------------- | ----------------------------------------------------------------------------------------------------- |
| Run as a Recurring Job | Choose whether to run this job as a recurring job.                                                    |
| Start Date/Time        | Date and time for when the first job will start.                                                      |
| End Date/Time          | Date and time for when the last job will finish.                                                      |
| Repeat Every           | Enter the number of recurrences in relation to the frequency of None, Minutes, Hours, Days or Months. |

## Steps finger tab

Nothing required within the **Steps** finger tab.

## Parameters finger tab

1. Go to the **Parameters** finger tab.
2. Click **Add Job Definition Parameter**.
3. For **Stored Procedure**, enter the name "**NightlyMaintenance**" as the **default value**. 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** and then click **Back** or using the breadcrumb trail, click **Nightly Maintenance Job**.
8. The newly created parameter should be displayed within the **Parameters** finger tab list.

## History finger tab

The **History** finger tab provides a list of previously run jobs and their respective metadata.

## Manually running the job

1. To manually start the job, click **More Options** and select **Schedule Job**.
2. From this window, choose **Date/Time.**
3. Using the **Yes/No** toggle, decide if it should run as a **Real Time Job** or not.
4. Click **Schedule Job**.
