# How to run Logstash with batch file through Task scheduler

**URL:** <https://discuss.elastic.co/t/how-to-run-logstash-with-batch-file-through-task-scheduler/234599>\
**Category:** Logstash\
**Created:** [May 27, 2020, 5:50pm UTC](https://discuss.elastic.co/t/how-to-run-logstash-with-batch-file-through-task-scheduler/234599 "2020-05-27T17:50:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chandra\_kunisetti](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chandra_kunisetti/32/69215_2.png) [@chandra\_kunisetti](https://discuss.elastic.co/u/chandra_kunisetti)\
**Post date:** [May 27, 2020, 5:50pm UTC](https://discuss.elastic.co/t/how-to-run-logstash-with-batch-file-through-task-scheduler/234599/1 "2020-05-27T17:50:57Z")

</div>

I have created a bacth file and tried to call it through Task scheduler. It is giving an error unable to launch. but am able to run manually(Without Scheduler) Its perfectly working .

Below is code for Batch :

@echo off

set root=F:\logstash-7.6.1\logstash-7.6.1\bin

CD %root%

call logstash -f F:\logstash-7.6.1\logstash-7.6.1\config\logstash\_delta.conf

exit /B 0

---

<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:** [May 27, 2020, 6:34pm UTC](https://discuss.elastic.co/t/how-to-run-logstash-with-batch-file-through-task-scheduler/234599/2 "2020-05-27T18:34:03Z")

</div>

You need to capture the output of the scheduled task (including stderr). logstash will be logging an error, maybe something like being unable to find java in the PATH.

See this [Q&A](https://stackoverflow.com/questions/8662024/how-do-i-capture-the-output-of-a-script-if-it-is-being-ran-by-the-task-scheduler) for advice. I definitely recommend the second answer over the first (i.e. include the 2\>&1)

---

<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:** [June 24, 2020, 6:34pm UTC](https://discuss.elastic.co/t/how-to-run-logstash-with-batch-file-through-task-scheduler/234599/3 "2020-06-24T18:34:04Z")

</div>

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