# `jadpo schedules`

Watch and control schedules.

Every schedule's state and runs are recorded in the database its state is kept in (area 12). `jadpo schedules` lists each schedule with its last run, when it is next due or that it is paused, and the alerts that hold: no successful run within twice its interval, ticks no longer arriving, a run past 80% of the 15-minute limit, three failures in a row, or a lease held past its expiry. `history` shows a schedule's runs and skipped ticks, newest first, 20 a page, and its metrics: runs, failures, skipped ticks, duration and delay. `pause` and `resume` stop and start its due ticks running it. `run` runs it now, under its lease, so it never runs twice at once: in this process against the database a running jadpo dev started, and otherwise by asking the app's own next tick, waiting for that run's record. The database is the one --url names, or the one its connection's setting gives, or the one a running jadpo dev started. Times are in UTC.

```text
jadpo schedules [action] [name]
```

## Arguments

- `action` (optional): What to do: run, pause, resume or history, or nothing to list them
- `name` (optional): The schedule's name

## Flags

- `--url <url>`: The database the schedules' state is in
- `--page <n>`: Which page of history, from 1, newest first

## On every command

- `--json`: Print data for tools instead of text
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo schedules --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"schedules"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# See every schedule, its last run and what is next
jadpo schedules
# See a schedule's past runs and its metrics
jadpo schedules history nightly_digest
# Stop a schedule running until it is resumed
jadpo schedules pause nightly_digest
# Run a schedule now
jadpo schedules run nightly_digest
```

## Errors

- [`cli.schedules_arguments`](../errors/cli.schedules_arguments.md): Schedules command has invalid arguments
- [`schedules.lease_held`](../errors/schedules.lease_held.md): Schedule is already running
- [`schedules.no_tick`](../errors/schedules.no_tick.md): No tick picked up the run asked for
- [`schedules.run_failed`](../errors/schedules.run_failed.md): Schedule's run failed
- [`schedules.unavailable`](../errors/schedules.unavailable.md): Schedules' database couldn't be read
- [`toolchain.project_not_found`](../errors/toolchain.project_not_found.md): Project could not be found
