# Run on a schedule

> Run a pipeline on a timetable, on the default branch or another one.
> **Available** in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its `.forge-ci.yaml` or `.xeonr-ci.yaml`. See [What is available](https://docs.branchd.run/branchd/pipelines#what-is-available).

```yaml title=".branchd/pipelines/nightly.yaml"
# .branchd/pipelines/nightly.yaml
# Runs on a timetable. Times are UTC. Each schedule has a name, unique in
# the repository, and a branch to run on (the default branch if empty).
name: Nightly
on:
  schedule:
    - name: nightly
      cron: '0 3 * * *'
    - name: weekly-stage
      cron: '30 6 * * 1'
      ref: stage
jobs:
  integration:
    image: golang:1.26
    timeout: 1h
    steps:
      - run: go test -tags integration ./...
  weekly-report:
    if: event == 'schedule' && branch == 'stage'
    image: alpine:3
    steps:
      - run: ./scripts/report.sh
```

- **`on: schedule`** is a list of `{cron, name, ref}`. `cron` has five fields
  (minute, hour, day of month, month, day of week), in UTC.
- **`name`** is unique in the repository, letters, digits, `.`, `_` and `-`,
  at most 64. Without one, a schedule is `<file name>-<n>` (`nightly-1`).
- **`ref`** is a branch; empty is the default branch.
- **`event == 'schedule'`** is true in a scheduled run, so one file can hold
  jobs for pushes and for schedules and tell them apart in `if:`.
- `timeout:` bounds a long job (`1h`, `90m`).
- **Limits.** A schedule fires at most every five minutes; a file holds at
  most 10 schedules and a repository 50. A file past any of them is refused.
- **Where they come from.** branchd keeps the repository's schedules in
  line with the pipeline files **on the default branch**: a push there that
  adds, changes or removes one updates them. A schedule in a file on another
  branch does nothing until it reaches the default branch. Each fire runs
  that file on the schedule's `ref`, at that branch's newest commit. The
  console can pause a file's schedule, not edit or delete it: change the
  file. A scheduled run reads with the job token and never writes
  `contents`, `releases` or `packages`, and it never starts a `trigger:`.
- **Check it locally:** `branchd ci plan --event schedule --schedule nightly`.

Source: https://docs.branchd.run/branchd/pipelines/schedules
