# Logstash upload to Elastic search works in Command Line but hangs when run through shell script

**URL:** https://discuss.elastic.co/t/logstash-upload-to-elastic-search-works-in-command-line-but-hangs-when-run-through-shell-script/45590
**Category:** Logstash
**Created:** [March 28, 2016, 1:49pm UTC](https://discuss.elastic.co/t/logstash-upload-to-elastic-search-works-in-command-line-but-hangs-when-run-through-shell-script/45590 "2016-03-28T13:49:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![shanbalasay](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@shanbalasay](https://discuss.elastic.co/u/shanbalasay)
#### Post date: [March 28, 2016, 1:49pm UTC](https://discuss.elastic.co/t/logstash-upload-to-elastic-search-works-in-command-line-but-hangs-when-run-through-shell-script/45590/1 "2016-03-28T13:49:01Z")

</div>

Executing logstash in command line worked successfully but putting the same command with the JAVA\_HOME & PATH variables set & exported in a shell script doesnt work. While running the shell script, logstash comes to the point showing the below, then it hangs/goes into an idefinite loop (on seeing the --debug output);

**Settings: Default pipeline workers: 16**  
**Logstash startup completed**

With the --debug and -v option in the logstash command, it repeats the below message continuously;  
\*\*Flushing buffer at interval \*\*

Why does it hang or go into indefinite loop while executing the same in a shell script ?

Note : ConfigTest is OK in both command line and shell script.

**Executing Logstash in Command Line in RHEL 5.8**  
$ JAVA\_HOME=../java/jdk1.8.0\_77/bin  
$ export PATH=$JAVA\_HOME:$PATH  
$ ../logstash-2.2.2/bin/logstash -f \_config\_file \< \_data\_file

**config\_file**  
input {  
stdin { }  
}

filter {  
grok {  
match =\> {  
"message" =\> "(?\<timestamp\>\d{,4}-\d{,2}-\d{,2}\s\d{,2}:\d{,2}:\d{,2}),(?[\w\_-]_),(?[\d]+),(?[\w\d.]_),(?[\w\d.]_),(?[\w\d.]_),(?[\d.]_),(?[\w;\s]_)"  
}  
}

date {  
match =\> ["timestamp", "YYYY-MM-dd HH:mm:ss"]  
}

mutate {  
convert =\> { "size" =\> "float" }  
convert =\> { "count" =\> "integer" }  
remove\_field =\> ["message", "@version", "\_id", "\_index", "\_type", "host"]  
}  
}

output {  
stdout { codec =\> dots }  
elasticsearch {  
hosts =\> ""  
index =\> ""  
}  
}

**data\_file**  
2010-10-10 10:10:10,name,1111,2222,3333,4444,5555,abc

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [March 28, 2016, 9:10pm UTC](https://discuss.elastic.co/t/logstash-upload-to-elastic-search-works-in-command-line-but-hangs-when-run-through-shell-script/45590/2 "2016-03-28T21:10:40Z")

</div>

What does your script look like?  
Why aren't you just using the RPM?

---

<div class="post-metadata">

### Author: ![shanbalasay](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@shanbalasay](https://discuss.elastic.co/u/shanbalasay)
#### Post date: [March 28, 2016, 9:18pm UTC](https://discuss.elastic.co/t/logstash-upload-to-elastic-search-works-in-command-line-but-hangs-when-run-through-shell-script/45590/3 "2016-03-28T21:18:04Z")

</div>

Hi Mark,

Thank you for your response;

Script looks like the below;

> #!/usr/bin/sh  
> JAVA\_HOME=../java/jdk1.8.0\_77/bin  
> export PATH=$JAVA\_HOME:$PATH  
> CONFIGFILE=configFilePath  
> DATAFILE=dataFilePath

> ../logstash-2.2.2/bin/logstash --configtest -f _CONFIGFILE_ \< _DATAFILE_  
> sleep 10  
> ../logstash-2.2.2/bin/logstash -f _CONFIGFILE_ \< _DATAFILE_

I downloaded the tar.gz file for the Linux O/S which I untarred as logstash-2.2.2, and using logstash as above. I'll try the RPM as well

Same result with RPM as well. logstash command hangs and goes into indefinite loop in debug.

---

<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 6, 2017, 5:03am UTC](https://discuss.elastic.co/t/logstash-upload-to-elastic-search-works-in-command-line-but-hangs-when-run-through-shell-script/45590/4 "2017-07-06T05:03:28Z")

</div>


