# On a schedule

> Starts on the days and at the time you choose.

Source: https://docs.go-lumen.ai/es/reference/triggers/on-schedule

## De un vistazo

| Propiedad | Valor |
| --- | --- |
| **Trigger name** | `on-schedule` |
| **Resource** | ClusterTrigger (`lumen.ai/v1alpha1`) |
| **Source** | schedule |
| **Needs a connection** | no |
| **Produces** | nothing |
| **Emits** | item |
| **Installation must provide** | nothing |

The trigger goes under `spec.triggers` of a Flow. Its outputs are referenced as `<triggerId>.<field>`. A trigger can also carry a `when` condition ("Start only when") and `disabled: true`.

## Salidas

Sin salidas con nombre: este disparador solo entrega los documentos a su primer nodo.

## Ajustes

Se definen bajo `config:` en el disparador del flujo.

| Ajuste | Tipo | Valor por defecto | Descripción |
| --- | --- | --- | --- |
| `cron` | string |  | Cron is a five-field cron expression: "0 9 1 \* \*" is 09:00 on the first of every month. Leave it out when Every is set. (minLength 1; maxLength 100) |
| `every` | object |  | Every runs it at a fixed interval, counted on the clock in TimeZone from midnight: every 15 minutes is :00, :15, :30, :45. Leave it out when Cron is set. |
| `every.value` (obligatorio) | integer |  | (minimum 1; maximum 1440) |
| `every.unit` (obligatorio) | string |  | Unit is minutes or hours. (one of minutes, hours) |
| `timeZone` | string |  | TimeZone is the IANA zone the cron is read in; unset is UTC. (minLength 1) |
| `startDate` | string |  | StartDate is the first day it may fire, YYYY-MM-DD in TimeZone. (pattern \`^\\d{4}-\\d{2}-\\d{2}$\`) |
| `endDate` | string |  | EndDate is the last day it may fire, YYYY-MM-DD in TimeZone. (pattern \`^\\d{4}-\\d{2}-\\d{2}$\`) |

El JSON Schema completo de estos ajustes: [on-schedule.schema.json](https://docs.go-lumen.ai/schemas/triggers/on-schedule.schema.json).

## Úsalo en un flujo

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: on-schedule-example
  namespace: tenant-acme
spec:
  displayName: "On a schedule"
  triggers:
    - id: start
      ref: {name: on-schedule}
      config:
        cron: "0 8 * * 1"
        timeZone: Asia/Jerusalem
      next: [notify-in-app]
  nodes:
    - id: notify-in-app
      stepRef: {name: notify-in-app}
      config:
        body: 'Total: {total}'
        title: New invoice from {supplier}
        to: admins
```
