---
title: "Schedule CLI reference"
description: "Customer-hosted cloud features"
---

# Schedule CLI reference

#### Customer-hosted cloud features

:::note
Some features are only available on customer-hosted clouds. Reach out to [support@anyscale.com](mailto:support@anyscale.com) for info.
:::

## Schedule CLI

### `anyscale schedule apply`

**Usage**

`anyscale schedule apply [OPTIONS]`

Create or Update a Schedule

The schedule should be specified in a YAML config file.

**Options**

-   **`--config-file/-f`**: Path to a YAML config file to use for this schedule. Command-line flags will overwrite values read from the file.
-   **`--name/-n`**: Name of the schedule.

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule apply -n my-schedule -f my-schedule.yaml
(anyscale +0.5s) Applying schedule with config ScheduleConfig(job_config=JobConfig(name='my-schedule', image_uri=None, compute_config=None, env_vars=None, py_modules=None, cloud=None, project=None, ray_version=None, job_queue_config=None), cron_expression='0 0 * * * *', timezone='UTC').
(anyscale +2.3s) Uploading local dir '.' to cloud storage.
(anyscale +3.7s) Including workspace-managed pip dependencies.
(anyscale +4.9s) Schedule 'my-schedule' submitted, ID: 'cronjob_vrjrbwcnfjjid7fsld3sfkn8jz'.

$ cat my-schedule.yaml
timezone: local
cron_expression: 0 0 * * * *
job_config:
    name: my-job
    entrypoint: python main.py
    max_retries: 5
```
:::

::::

### `anyscale schedule list`

**Usage**

`anyscale schedule list [OPTIONS]`

List Schedules

You can optionally filter schedules by name, project, cloud, or creator.

**Options**

-   **`--v2`**: \[RECOMMENDED\] Enable extended filtering options. Needs migration to match return values.
-   **`--name/-n`**: Filter by the name of the schedule.
-   **`--id/-i`**: Id of the schedule.
-   **`--project`**: The named Anyscale Project for the schedule. If not provided, the organization default will be used (or, if running in a workspace, the project of the workspace). Only with --v2 flag.
-   **`--cloud`**: The named Anyscale Cloud for the schedule. If not provided, the organization default will be used (or,if running in a workspace, the cloud of the workspace). Only with --v2 flag.
-   **`--creator-id`**: Filter by creator ID. Only with --v2 flag.
-   **`--max-items`**: Max total items (only with --no-interactive).
-   **`--page-size`**: Number of items per page (1-50). Only with --v2.
-   **`--sort`**: Sort by field. Prefix with '-' for descending order. Defaults to -created\_at. Allowed: NAME, ID, CREATED\_AT, NEXT\_TRIGGER\_AT. Only with --v2.
-   **`--json/-j`**: Output results as JSON. Only with --v2.
-   **`--interactive/--no-interactive`**: Enable interactive pagination. Only with --v2.
-   **`--include-all-users/--only-mine`**: Include schedules from all users. Only with --v2.

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule list -n my-schedule
Output
+------------------------------------+-------------+---------------+-----------+-------------+------------------+------------+------------------+-----------------------+
| ID                                 | NAME        | DESCRIPTION   | PROJECT   | CRON        | NEXT TRIGGER     | TIMEZONE   | CREATOR          | LATEST EXECUTION ID   |
|------------------------------------+-------------+---------------+-----------+-------------+------------------+------------+------------------+-----------------------|
| cronjob_vrjrbwcnfjjid7fsld3sfkn8jz | my-schedule |               | default   | 0 0 * * * * | 2 hours from now | UTC        | doc@anyscale.com |                       |
+------------------------------------+-------------+---------------+-----------+-------------+------------------+------------+------------------+-----------------------+
```
:::

::::

### `anyscale schedule pause`

**Usage**

`anyscale schedule pause [OPTIONS]`

Pause a Schedule.

You can pause a schedule by config file, name, or id.

To specify the schedule by name, use the --name flag. You can specify the cloud with --cloud and the project with --project.

To specify the schedule by id, use the --id flag.

To specify the schedule by config file, use --config-file. Ensure that name and optionally cloud and project are specified in the config file's job config.

**Options**

-   **`--config-file/-f`**: Path to a YAML config file to use for this schedule.
-   **`--name/-n`**: Name of the schedule.
-   **`--id/-i`**: Id of the schedule.
-   **`--cloud`**: The named Anyscale Cloud for the schedule. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).
-   **`--project`**: Named project to use for the schedule. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule pause -n my-schedule
(anyscale +3.6s) Set schedule 'my-schedule' to state DISABLED
```
:::

::::

### `anyscale schedule resume`

**Usage**

`anyscale schedule resume [OPTIONS]`

Resume a Schedule

You can resume a schedule by config file, name, or id.

To specify the schedule by name, use the --name flag. You can specify the cloud with --cloud and the project with --project.

To specify the schedule by id, use the --id flag.

To specify the schedule by config file, use --config-file. Ensure that name and optionally cloud and project are specified in the config file's job config.

**Options**

-   **`--config-file/-f`**: Path to a YAML config file to use for this schedule.
-   **`--name/-n`**: Name of the schedule.
-   **`--id/-i`**: Id of the schedule.
-   **`--cloud`**: The named Anyscale Cloud for the schedule. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).
-   **`--project`**: Named project to use for the schedule. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule resume -n my-schedule
(anyscale +4.1s) Set schedule 'my-schedule' to state ENABLED
```
:::

::::

### `anyscale schedule status`

**Usage**

`anyscale schedule status [OPTIONS]`

Query the status of a Schedule.

You can query the status of a schedule by config file, name, or id.

To specify the schedule by name, use the --name flag. You can specify the cloud with --cloud and the project with --project.

To specify the schedule by id, use the --id flag.

To specify the schedule by config file, use --config-file. Ensure that name and optionally cloud and project are specified in the config file's job config.

**Options**

-   **`--config-file/-f`**: Path to a YAML config file to use for this schedule.
-   **`--name/-n`**: Name of the schedule.
-   **`--id/-i`**: Id of the schedule.
-   **`--cloud`**: The named Anyscale Cloud for the schedule. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).
-   **`--project`**: Named project to use for the schedule. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).
-   **`--json/-j`**: Output the status in a structured JSON format.
-   **`--verbose/-v`**: Include verbose details in the status.

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule status -n my-schedule
id: cronjob_vrjrbwcnfjjid7fsld3sfkn8jz
name: my-schedule
state: ENABLED
```
:::

::::

### `anyscale schedule run`

**Usage**

`anyscale schedule run [OPTIONS]`

Manually run a Schedule

This function takes an existing schedule and runs it now. You can specify the schedule by name or id. You can also pass in a YAML file as a convinience. This is equivalent to passing in the name specified in the YAML file. IMPORTANT: if you pass in a YAML definition that differs from the Schedule defition, the Schedule will NOT be updated. Please use the `anyscale schedule apply` command to update the configuration of your schedule or use the `anyscale job submit` command to submit a one off job that is not a part of a schedule.

**Options**

-   **`--config-file/-f`**: Path to a YAML config file to use for this schedule.
-   **`--name/-n`**: Name of the schedule.
-   **`--id/-i`**: Id of the schedule.
-   **`--cloud`**: The named Anyscale Cloud for the schedule. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).
-   **`--project`**: Named project to use for the schedule. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule run -n my-schedule
(anyscale +2.5s) Triggered job for schedule 'my-schedule'.
```
:::

::::

### `anyscale schedule url`

**Usage**

`anyscale schedule url [OPTIONS] [SCHEDULE_CONFIG_FILE]`

Get a Schedule URL

This function accepts 1 argument, a path to a YAML config file that defines this schedule. You can also specify the schedule by name or id.

**Options**

-   **`--name/-n`**: Name of the schedule.
-   **`--id/-i`**: Id of the schedule.
-   **`--v2`**: Use new SDK-based implementation
-   **`--cloud`**: Cloud name (required with --name in v2 mode)
-   **`--project`**: Project name (required with --name in v2 mode)

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule url -n my-schedule
Output
(anyscale +2.3s) View your schedule at https://console.anyscale.com/scheduled-jobs/cronjob_7zj
```
:::

::::

### `anyscale schedule delete`

**Usage**

`anyscale schedule delete [OPTIONS]`

Delete a Schedule.

If the schedule is active, it will be automatically paused before deletion. The schedule must have no active triggered jobs.

To specify the schedule by id, use the --id flag.

To specify the schedule by name, use the --name flag along with --cloud and --project.

**Options**

-   **`--name/-n`**: Name of the schedule.
-   **`--id/-i`**: Id of the schedule.
-   **`--cloud`**: The named Anyscale Cloud for the schedule (required with --name).
-   **`--project`**: Named project for the schedule (required with --name).

#### Examples

::::tabs

:::tab[CLI]
```bash
$ anyscale schedule delete --id cronjob_vrjrbwcnfjjid7fsld3sfkn8jz
(anyscale +2.3s) Schedule 'my-schedule' deleted.

$ anyscale schedule delete --name my-schedule --cloud my-cloud --project my-project
(anyscale +2.5s) Schedule 'my-schedule' deleted.
```
:::

::::

## Schedule models

### `ScheduleConfig`

Configuration options for a schedule.

#### Fields

-   **`job_config` (Dict | [JobConfig](/reference/sdk/job.md#jobconfig))**: Configuration of the job.
-   **`cron_expression` (str)**: A cron expression to define the frequency at which to run this cron job, for example '0 0 \* \* \*' is a cron expression that means 'run at midnight'. Visit crontab.guru to construct a precise cron\_expression.
-   **`timezone` (str)**: The timezone in which to interpret the cron\_expression. Default is Universal time (UTC). You can specify 'local' to use the local timezone

#### Python Methods

```python
def __init__(self, **fields) -> ScheduleConfig
    """Construct a model with the provided field values set."""

def options(self, **fields) -> ScheduleConfig
    """Return a copy of the model with the provided field values overwritten."""

def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[YAML]
```yaml
timezone: local
cron_expression: 0 0 * * * *
job_config:
    name: my-schedule-job
    entrypoint: python main.py
    max_retries: 5
```
:::

:::tab[Python]
```python
from anyscale.schedule.models import ScheduleConfig
from anyscale.job.models import JobConfig

config = ScheduleConfig(
    job_config=JobConfig(
        entrypoint="python main.py"
    ),
    timezone="local",
    cron_expression="0 0 * * *"
)
```
:::

::::

### `ScheduleState`

Current state of a schedule.

#### Values

-   **`ENABLED`**: The schedule is enabled. Jobs will be started according to this jobs cron expression.
-   **`DISABLED`**: The schedule is disabled. No jobs will be started until the schedule is reenabled.

### `ScheduleStatus`

Current status of a schedule.

#### Fields

-   **`config` ([ScheduleConfig](#scheduleconfig))**: Configuration of the schedule.
-   **`id` (str)**: Unique ID of the schedule (generated when the schedule is first submitted).
-   **`name` (str)**: Name of the schedule.
-   **`state` (str | [ScheduleState](#schedulestate))**: Current state of the schedule.

#### Python Methods

```python
def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale
from anyscale.schedule.models import ScheduleStatus
status: ScheduleStatus = anyscale.schedule.status(name="my-schedule")
```
:::

:::tab[CLI]
```bash
$ anyscale schedule status -n my-schedule
id: cronjob_dfhqufws6s3issltpjgrdzcgyc
name: my-schedule
state: ENABLED
```
:::

::::

### `ScheduleSortField`

Fields available for sorting schedules.

#### Values

-   **`NAME`**: Sort by schedule name.
-   **`ID`**: Sort by schedule ID.
-   **`CREATED_AT`**: Sort by creation timestamp.
-   **`NEXT_TRIGGER_AT`**: Sort by next trigger timestamp.

---

Previous: [Resource quotas](/reference/cli/resource-quotas.md) | Next: [SCIM](/reference/cli/scim.md)