# Execute logstash as service on startup

**URL:** <https://discuss.elastic.co/t/execute-logstash-as-service-on-startup/94086>\
**Category:** Logstash\
**Created:** [July 21, 2017, 9:25am UTC](https://discuss.elastic.co/t/execute-logstash-as-service-on-startup/94086 "2017-07-21T09:25:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danilo\_Giacchi](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@Danilo\_Giacchi](https://discuss.elastic.co/u/Danilo_Giacchi)\
**Post date:** [July 21, 2017, 9:25am UTC](https://discuss.elastic.co/t/execute-logstash-as-service-on-startup/94086/1 "2017-07-21T09:25:12Z")

</div>

Hi i am new to Logstash and i am using the version 5.5.0 and elasticsearch 5.5.0 on xubuntu 16.04.  
I'm trying to create a bridge between postgresql 9.6.0 and elasticsearch.  
I'm able to execute logstash with configuration file (logstash.conf) in order to manage insert update and delete on postgres.

```
input {
jdbc {
    jdbc_connection_string => "jdbc:postgresql://localhost:5432/BSS"
    jdbc_user => "postgres"
tags => ["prodCanc"]
jdbc_password => " *******"
    jdbc_validate_connection => true
    jdbc_driver_library => "/home/danilo/Desktop/postgresql-42.1.3.jar"
    jdbc_driver_class => "org.postgresql.Driver"
    statement => "SELECT * from prodotti_cancellati"
}
}
output {
if "prodCanc" in [tags]{
	    elasticsearch {
	 action => "delete"
	 index => "prodotti"
	 document_type => "product"
   		 document_id => "%{id}"
   		 hosts => "localhost:9200"

    }
}
}

input {
jdbc {
    jdbc_connection_string => "jdbc:postgresql://localhost:5432/BSS"
    jdbc_user => "postgres"
    tags => ["prodotti"]
    jdbc_password => " ******"
    jdbc_validate_connection => true
    jdbc_driver_library => "/home/danilo/Desktop/postgresql-42.1.3.jar"
    jdbc_driver_class => "org.postgresql.Driver"
    statement => "SELECT * from prodotti"
}
}
output {
    if "prodotti" in [tags]{
        elasticsearch {

             index => "prodotti"

             document_type => "product"
             document_id => "%{id}"
             hosts => "localhost:9200"
        }
    }
}

```

I am running logstash with following command and it works perfectly:  
sudo /usr/share/logstash/bin/logstash -f /etc/logstash/logstash.conf

Now I need to execute logstash with this configuration on startup and I need to automatically listen for change on postgres database.  
Thanks in advance for any reply.

---

<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:** [July 25, 2017, 8:49pm UTC](https://discuss.elastic.co/t/execute-logstash-as-service-on-startup/94086/2 "2017-07-25T20:49:18Z")

</div>

I'm not sure what you're having problems with. Running Logstash as a service on Ubuntu is documented here: [https://www.elastic.co/guide/en/logstash/current/running-logstash.html](https://www.elastic.co/guide/en/logstash/current/running-logstash.html)

---

<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:** [August 22, 2017, 8:49pm UTC](https://discuss.elastic.co/t/execute-logstash-as-service-on-startup/94086/3 "2017-08-22T20:49:30Z")

</div>

Closed on August 22, 2017, 8:49pm UTC

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