# Filebeat installation as service but under custom folder

**URL:** https://discuss.elastic.co/t/filebeat-installation-as-service-but-under-custom-folder/152915
**Category:** Beats
**Tags:** filebeat
**Created:** [October 17, 2018, 9:30pm UTC](https://discuss.elastic.co/t/filebeat-installation-as-service-but-under-custom-folder/152915 "2018-10-17T21:30:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![shivaprasadrao.b](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@shivaprasadrao.b](https://discuss.elastic.co/u/shivaprasadrao.b)
#### Post date: [October 17, 2018, 9:30pm UTC](https://discuss.elastic.co/t/filebeat-installation-as-service-but-under-custom-folder/152915/1 "2018-10-17T21:30:38Z")

</div>

I have setup filbeat using below:  
**curl -L -O [https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.4.0-x86\_64.rpm](https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.4.0-x86_64.rpm)**  
**sudo rpm -vi filebeat-6.4.0-x86\_64.rpm**

Filebeat is successfully set up as service, but the filebeat related files like filebeat.yml is created under **/etc/filebeat/filebeat.yml** and log file in **/var/log/filebeat**.

My question is can i install filebeat as service as above but all the filebeat related files should be under my custom folder say **/opt/ELK/filebeat** instead of **/etc/filebeat/filebeat.yml** or **/var/log/filebeat**.

Is this possible ?  
Thanks in advance.

---

<div class="post-metadata">

### Author: ![shivaprasadrao.b](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@shivaprasadrao.b](https://discuss.elastic.co/u/shivaprasadrao.b)
#### Post date: [October 18, 2018, 9:02pm UTC](https://discuss.elastic.co/t/filebeat-installation-as-service-but-under-custom-folder/152915/2 "2018-10-18T21:02:55Z")

</div>

I have achieved this by using system service.Below are the details:

i have created filebeat.service with below details:  
[Unit]  
Description=filebeat

[Service]  
ExecStart=/opt/ELK/filebeat.sh

[Install]  
WantedBy=multi-user.target

and my filebeat.sh has below data:  
#!/bin/sh  
dstamp=`date '+%Y%m%d%H%M'`  
LOG\_FILE=/opt/ELK/filebeat.log  
sDate=`date '+%Y-%m-%d %r'`

echo $sDate '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' \>\> $LOG\_FILE

echo $sDate 'Start of filebeat' \>\> $LOG\_FILE

cd /opt/ELK/filebeat-6.4.0-linux-x86\_64  
./filebeat -e -c filebeat.yml -d "publish"

echo $sDate 'END of filebeat' \>\> $LOG\_FILE  
echo $sDate '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::' \>\> $LOG\_FILE

after that run below commands:  
systemctl enable filebeat  
systemctl status filebeat  
systemctl start filebeat  
systemctl stop filebeat

---

<div class="post-metadata">

### Author: ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)
#### Post date: [October 19, 2018, 12:28pm UTC](https://discuss.elastic.co/t/filebeat-installation-as-service-but-under-custom-folder/152915/3 "2018-10-19T12:28:25Z")

</div>

Have you considered to install filebeat from the tgz file or create your own rpm based on the tgz file? When installing via `rpm`, the rpm database tracks installed packages and files/locations. Moving files kind of messes with these meta-data. Plus, when updating filebeat via rpm you don't want it to overwrite your systemd script.

---

<div class="post-metadata">

### Author: ![shivaprasadrao.b](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@shivaprasadrao.b](https://discuss.elastic.co/u/shivaprasadrao.b)
#### Post date: [October 31, 2018, 8:33am UTC](https://discuss.elastic.co/t/filebeat-installation-as-service-but-under-custom-folder/152915/4 "2018-10-31T08:33:14Z")

</div>

Hey Steffens,

I installed filebeat from .tar.gz .  
I have unzipped the tar.gz in my custom location it and made necessary changes to .yml file.  
Then i have created services as per my requirement.

Thanks  
Shivaprasad

---

<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: [November 28, 2018, 8:46am UTC](https://discuss.elastic.co/t/filebeat-installation-as-service-but-under-custom-folder/152915/5 "2018-11-28T08:46:10Z")

</div>

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