# How schedule periodic task but execute when Logstash instance starts?

**URL:** <https://discuss.elastic.co/t/how-schedule-periodic-task-but-execute-when-logstash-instance-starts/238899>\
**Category:** Logstash\
**Created:** [June 26, 2020, 6:13pm UTC](https://discuss.elastic.co/t/how-schedule-periodic-task-but-execute-when-logstash-instance-starts/238899 "2020-06-26T18:13:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabio\_Naspolini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabio_naspolini/32/62070_2.png) [@Fabio\_Naspolini](https://discuss.elastic.co/u/Fabio_Naspolini)\
**Post date:** [June 26, 2020, 6:13pm UTC](https://discuss.elastic.co/t/how-schedule-periodic-task-but-execute-when-logstash-instance-starts/238899/1 "2020-06-26T18:13:37Z")

</div>

How schedule periodic task but execute on Logstash instance starts?

I need to schedule tasks to execute every hour, but I need force re-execute this when Logstash service restarted.  
How to do this?

Thank you!

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 26, 2020, 7:22pm UTC](https://discuss.elastic.co/t/how-schedule-periodic-task-but-execute-when-logstash-instance-starts/238899/2 "2020-06-26T19:22:43Z")

</div>

Does your configuration have an input that has a schedule option? If so, what does it look like?

---

<div class="post-metadata">

**Author:** ![Fabio\_Naspolini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabio_naspolini/32/62070_2.png) [@Fabio\_Naspolini](https://discuss.elastic.co/u/Fabio_Naspolini)\
**Post date:** [June 29, 2020, 10:06pm UTC](https://discuss.elastic.co/t/how-schedule-periodic-task-but-execute-when-logstash-instance-starts/238899/3 "2020-06-29T22:06:27Z")

</div>

Hi,  
My schedule setting is this.  
5 min recorrence, but I would like execute job when logstash service restart.  
Is there any way?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/8/d878d356a5fe500e8d9957078179e7fcd7086c30.png)

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 29, 2020, 10:35pm UTC](https://discuss.elastic.co/t/how-schedule-periodic-task-but-execute-when-logstash-instance-starts/238899/4 "2020-06-29T22:35:29Z")

</div>

You could try adding a second http\_poller input, with a schedule of at =\> "now". That would execute once when logstash started. You would have to replicate all the urls configuration.

---

<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:** [July 27, 2020, 10:35pm UTC](https://discuss.elastic.co/t/how-schedule-periodic-task-but-execute-when-logstash-instance-starts/238899/5 "2020-07-27T22:35:33Z")

</div>

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