# Logstash runs from command line but not as a service

**URL:** <https://discuss.elastic.co/t/logstash-runs-from-command-line-but-not-as-a-service/2599>\
**Category:** Logstash\
**Created:** [June 12, 2015, 7:44pm UTC](https://discuss.elastic.co/t/logstash-runs-from-command-line-but-not-as-a-service/2599 "2015-06-12T19:44:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuayre](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@stuayre](https://discuss.elastic.co/u/stuayre)\
**Post date:** [June 12, 2015, 7:44pm UTC](https://discuss.elastic.co/t/logstash-runs-from-command-line-but-not-as-a-service/2599/1 "2015-06-12T19:44:41Z")

</div>

I have logstash and elastic search installed.

I'm trying to get logstash to read a csv file and populate ES

everything works fine when I run logstash from the command line using:

sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/products.conf

but when running the logstash service the csv file isn't read and no index is created.

I've tried:

chmod 777 the csv file  
moving the csv to /tmp/  
editing the logstash config file (/etc/init.d/logstash) and changing LS\_USER=root

i've checked my config file with --configtest and everything is ok

how do I get the logstash service to read the csv file?

i'm using CentOS 6.5

this is the output from the logstash.stdout log:

Writing garbage collection logs to ./logstash-gc.log  
Sending logstash logs to /var/log/logstash/logstash.log.  
Error: Expected one of #, input, filter, output at line 1, column 1 (byte 1) af$  
You may be interested in the '--configtest' flag which you can  
use to validate logstash's configuration before you choose  
to restart a running system.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [June 12, 2015, 8:25pm UTC](https://discuss.elastic.co/t/logstash-runs-from-command-line-but-not-as-a-service/2599/2 "2015-06-12T20:25:54Z")

</div>

> sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/products.conf

You should never run Logstash as root, not even for testing.

> this is the output from the logstash.stdout log:

> Writing garbage collection logs to ./logstash-gc.log  
> Sending logstash logs to /var/log/logstash/logstash.log.  
> Error: Expected one of #, input, filter, output at line 1, column 1 (byte 1) af$  
> You may be interested in the '--configtest' flag which you can  
> use to validate logstash's configuration before you choose  
> to restart a running system.

You probably have another file in /etc/logstash/conf.d that Logstash has a problem with. Logstash will read all files from that directory.

---

<div class="post-metadata">

**Author:** ![stuayre](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@stuayre](https://discuss.elastic.co/u/stuayre)\
**Post date:** [June 12, 2015, 8:50pm UTC](https://discuss.elastic.co/t/logstash-runs-from-command-line-but-not-as-a-service/2599/3 "2015-06-12T20:50:00Z")

</div>

> [@](#):
>
> You probably have another file in /etc/logstash/conf.d that Logstash has a problem with. Logstash will read all files from that directory.

yeah I did!! I had a random file in there, so I deleted it and it's all working now!! thanks for your help! 😸

> [@](#):
>
> You should never run Logstash as root, not even for testing.

ok noted! thanks!

---

<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:37am UTC](https://discuss.elastic.co/t/logstash-runs-from-command-line-but-not-as-a-service/2599/4 "2017-07-06T05:37:31Z")

</div>


