# How do I build a beat to work as a service on linux

**URL:** <https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682>\
**Category:** Beats\
**Created:** [April 18, 2016, 4:31pm UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682 "2016-04-18T16:31:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![adi.b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adi.b/32/8581_2.png) [@adi.b](https://discuss.elastic.co/u/adi.b)\
**Post date:** [April 18, 2016, 4:31pm UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682/1 "2016-04-18T16:31:27Z")

</div>

Hi,  
I'm writing a new beat (will be posted when done) and I was wondering how do I build the beat as a service on Linux system?

In windows I just used the PS script to create a service - easy.  
But for Linux I see that the original beats are using something called \*beat-god (for example, topbeat-god), what is it and how do I use it with my beat?

Thanks,  
Adi.

---

<div class="post-metadata">

**Author:** ![tudor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tudor/32/3753_2.png) [@tudor](https://discuss.elastic.co/u/tudor)\
**Post date:** [April 18, 2016, 9:40pm UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682/2 "2016-04-18T21:40:09Z")

</div>

It's this [project](https://github.com/fiorix/go-daemon). We use it because Go doesn't make it easy to daemonize properly. We only use it in the init scripts, if systemd is available, we use that instead.

For creating all the packages we use "beats packer", which you can find [here](https://github.com/elastic/beats/tree/master/dev-tools/packer). If you used the [Beat Generator](https://github.com/elastic/beat-generator) to bootstrap your beat, it should be pretty easy to use it yourself. See the [Package](https://github.com/elastic/beat-generator/tree/master/%7B%7Bcookiecutter.beat%7D%7D#package) section in the README.

Let me know if you hit any issues, I did change a few things recently in the packer.

---

<div class="post-metadata">

**Author:** ![adi.b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adi.b/32/8581_2.png) [@adi.b](https://discuss.elastic.co/u/adi.b)\
**Post date:** [April 19, 2016, 12:04pm UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682/3 "2016-04-19T12:04:29Z")

</div>

Thanks Tudor!! works flawlessly!

---

<div class="post-metadata">

**Author:** ![adi.b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adi.b/32/8581_2.png) [@adi.b](https://discuss.elastic.co/u/adi.b)\
**Post date:** [April 19, 2016, 2:54pm UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682/4 "2016-04-19T14:54:57Z")

</div>

Actually, one more question please...

It only built 2 rpms - for Linux, and on the documentation it says that if I run:  
make clean && make -j2

it will build for all OS, did I do something wrong?

---

<div class="post-metadata">

**Author:** ![tudor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tudor/32/3753_2.png) [@tudor](https://discuss.elastic.co/u/tudor)\
**Post date:** [April 19, 2016, 2:57pm UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682/5 "2016-04-19T14:57:49Z")

</div>

It should build for all OSes, yes. Does it print any errors? I'd leave out the `-j2`, btw.

---

<div class="post-metadata">

**Author:** ![adi.b](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adi.b/32/8581_2.png) [@adi.b](https://discuss.elastic.co/u/adi.b)\
**Post date:** [April 20, 2016, 8:53am UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682/6 "2016-04-20T08:53:51Z")

</div>

worked after dropping the `-j2`.

Thanks again!

---

<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 5, 2017, 9:53pm UTC](https://discuss.elastic.co/t/how-do-i-build-a-beat-to-work-as-a-service-on-linux/47682/7 "2017-07-05T21:53:00Z")

</div>


