# Trigger schedule without time intervals

**URL:** <https://discuss.elastic.co/t/trigger-schedule-without-time-intervals/252267>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring, elastic-stack-alerting\
**Created:** [October 15, 2020, 8:23pm UTC](https://discuss.elastic.co/t/trigger-schedule-without-time-intervals/252267 "2020-10-15T20:23:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_David\_Jaramillo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juan_david_jaramillo/32/76831_2.png) [@Juan\_David\_Jaramillo](https://discuss.elastic.co/u/Juan_David_Jaramillo)\
**Post date:** [October 15, 2020, 8:23pm UTC](https://discuss.elastic.co/t/trigger-schedule-without-time-intervals/252267/1 "2020-10-15T20:23:38Z")

</div>

**hello, how can I make the trigger schedule run once and not have any time interval but only run once and already.**

```auto
{
  "trigger": {
    "schedule": {
      "interval": "1h"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "agenteallot*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "size": 0,
          "query": {
            "bool": {
              "filter": [
                {
                  "range": {
                    "@timestamp": {
                      "gte": "{{ctx.trigger.scheduled_time}}||-5m",
                      "lte": "{{ctx.trigger.scheduled_time}}",
                      "format": "strict_date_optional_time||basic_time_no_millis"
                    }
                  }
                },
                {
                  "term": {
                    "monitor.name.keyword": "01-1-CAV30328203-DATOS-PPAL-2.7G-99.98"
                  }
                }
              ]
            }
          },
          "aggs": {
            "metricAgg": {
              "max": {
                "field": "summary.down"
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "script": {
      "source": " while (ctx.payload.aggregations.metricAgg.value != params.threshold ) {return=true; } return=false;",
      "lang": "painless",
      "params": {
        "threshold": 0
      }
    }
  },
  "actions": {
    "email_1": {
      "email": {
        "profile": "standard",
        "attach_data": {
          "format": "json"
        },
        "to": [
          "juan.jaramillo@megadvantage.com",
          "juancho.jaramillo16@gmail.com",
          "victor.vera@megadvantage.com"
        ],
        "subject": "{{ctx.metadata.name}} 01-1-CAV30328203-DATOS-PPAL-2.7G-99.98",
        "body": {
          "text": """Buen dia, Adjunto registro del reporte.

 ⚠️ALERTA NODO!!! El siguiente enlace perdió la conexión. 

 Estado: Down🔴 

 Nombre del Enlace: 01-1-CAV30328203-DATOS-PPAL-2.7G-99.98

 🕧Hora: {{ctx.execution_time}} {{ctx.result.execution_time}}

 Área: Networking 

 🔔Mensaje Alerta: El enlace ha dejado de responder. Responder correo a telecomunicaciones@udistrital.edu.co 

 Ingrese aquí para más información: https://72dfe17217744236af40cc31b704a664.us-central1.gcp.cloud.es.io:9243/s/distrital/app/uptime#"""
        }
      }
    }
  },
  "transform": {
    "script": {
      "source": "HashMap result = new HashMap(); result.result = ctx.payload.aggregations.metricAgg.value; return result;",
      "lang": "painless",
      "params": {
        "threshold": 0
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 16, 2020, 1:58pm UTC](https://discuss.elastic.co/t/trigger-schedule-without-time-intervals/252267/2 "2020-10-16T13:58:42Z")

</div>

See the [cron schedule](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/trigger-schedule.html#schedule-cron)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 13, 2020, 1:58pm UTC](https://discuss.elastic.co/t/trigger-schedule-without-time-intervals/252267/3 "2020-11-13T13:58:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
