# Create Schedules

## Overview

In OneLens, you can create **Schedules** to automate routine resource management tasks and avoid unnecessary manual effort. Each OneLens schedule allows you to specify:

* **Which service and resources** the schedule applies to
* **What action** should be performed (start, stop, or scale)
* **When and how often** the action should run (daily, weekly, or monthly)

Once you understand the value of schedules, the next step is to learn how to set one up inside OneLens.

## Steps to Create

Here’s how you can create a schedule in OneLens:

{% stepper %}
{% step %}

### Head to Schedulers

* Log in to the [**OneLens UI**](https://app-in.onelens.cloud/).
* From the right sidebar, click **Schedulers**.

{% hint style="warning" %}

## **Note**

If you haven’t installed the Scheduler yet, you’ll see the *Getting Started with Scheduler* page. To continue, follow the [Scheduler Installation Guide](/automate/schedulers/install-schedulers.md).
{% endhint %}
{% endstep %}

{% step %}

### Create a New Schedule

* Click on **Create New Schedule** in the top-right corner.

A form appears where you define the schedule name, frequency, and the set of rules (expressions) that determine which resources the schedule applies to.

<figure><img src="/files/mtDxTJAx51DFOnsf4TO7" alt="" width="375"><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Enter General Details

Give your schedule its basic identity:

* **Schedule Name** – Name your schedule so you can easily identify it later.
* **Schedule Service** – Select the AWS service you want to automate (EC2, RDS, or ASG).
* **Description** – Add a short description to explain the purpose of your schedule.

  <figure><img src="/files/3kgw2NbhqMQsrlJes57x" alt="" width="563"><figcaption></figcaption></figure>

{% endstep %}

{% step %}

### Choose Target Scope

You decide which resources the schedule applies to by:

#### **a) Using Expression-Based Rules**

* Add **rules** by choosing a **field**, an **operator**, and a **value**.
  * **Available Fields**: Account, Region, Tags.
* Combine multiple rules with valid operators.
* **Valid operators:** `AND`, `(`, `)`.

  <figure><img src="/files/Az2W4UnEMD82gvn2wQi0" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}

## Business Usecase

Imagine you want to optimize non-critical workloads in different environments by automatically shutting them down during off-hours. You decide to use expression-based rules to precisely target the right set of resources across multiple accounts and regions.

You create the following rules:

* **Rule 1:** Account = `Account-1`
* **Rule 2:** Region = `us-east-1`
* **Rule 3:** Account = `Account-2`
* **Rule 4:** Region = `us-west-2`
* **Rule 5:** Tag = `non-prod`

The expression looks like:\
\&#xNAN;**`(1 AND 2) AND (3 AND 4 AND 5)`**

Here’s how it works:

* **Group 1 (1 AND 2):** Targets all resources in **Account-1** that are located in **us-east-1**.
* **Group 2 (3 AND 4 AND 5):** Targets all resources in **Account-2**, within **us-east-3**, and tagged as **non-prod**.

The scheduler now applies to **both groups of resources**. That means during off-hours, it will stop all workloads from Group 1 and Group 2, ensuring cost savings without impacting production-critical services.
{% endhint %}

#### **b) Using Resource ID**

* Click **Add Resource** and enter the **ARN** of a resource, or
* Upload a CSV file with multiple ARNs.

  <figure><img src="/files/mrhLwfclUZB0S630JHZD" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="warning" %}
**Note:** You can add up to 50 resources only.
{% endhint %}
{% endstep %}

{% step %}

### Add Schedule Actions

Once the schedule is created, you can define what action should take place:

1. **Click on Add Action**.
2. A configuration box appears where you need to define:

* **Action Type**
  * The available action types vary depending on the service:
    * **EC2** → Start or Stop Instance
    * **RDS** → Start or Stop Resource
    * **Auto Scaling Group (ASG)** → Modify Resource

{% hint style="warning" %}

## Important

For ASG resources, you must additionally provide:

* **Min Size**

* **Desired Capacity**

* **Max Size**
  {% endhint %}

* **Action Recurrence**
  * Define how often the action should run:
    * **Daily** → Choose excluded days
    * **Weekly** → Select the day(s) of the week
    * **Monthly** → Select the day of the month

* **Time of the Day (UTC)**
  * Set the exact hour and minute when the action should be executed.

    <figure><img src="/files/PnMf8zoP5fkZdcsmRkmo" alt="" width="375"><figcaption></figcaption></figure>

* Click on **Add Action**.

{% hint style="info" %}

## Note

You can add multiple actions under a single schedule. However, ensure that the **timing of each action does not collide**, as overlapping schedules may cause conflicts in resource management.
{% endhint %}

{% hint style="success" %}

## **Business Usecase**

Suppose you want to reduce costs by stopping non-production EC2 instances every Friday evening. You can configure the following:

* an **EC2 Stop Instance** action,&#x20;
* set the **recurrence to weekly**, choose **Friday**,&#x20;
* and define the **execution time as 19:00 UTC**.&#x20;
  {% endhint %}
  {% endstep %}

{% step %}

### Save the Schedule

* Once you’ve entered all details, click **Create Schedule**.
* Your schedule is now active, and OneLens will execute it exactly as you defined.
  {% endstep %}
  {% endstepper %}

After you’ve created schedules, head to your [Schedulers Dashboard](/automate/schedulers/schedulers-dashboard.md) to monitor and manage them in one place.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.onelens.cloud/automate/schedulers/create-schedules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
