# How to run metricbeat in background?

**URL:** <https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595>\
**Category:** Beats\
**Tags:** filebeat, metricbeat, winlogbeat\
**Created:** [February 8, 2021, 12:28pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595 "2021-02-08T12:28:59Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaiksubhan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shaiksubhan](https://discuss.elastic.co/u/shaiksubhan)\
**Post date:** [February 8, 2021, 12:28pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/1 "2021-02-08T12:28:59Z")

</div>

Hi Team,  
I am trying to install Metricbeat 7.10.1 Linux version on my Linux machine but I am unable to run the metricbeat in the Background.  
Can any one help me on this so that i can run this beat in background itself

I tried  
" sudo ./metricbeat and if I close terminal Beat also Stopped  
Another scnario is if I give command like "sudo ./metirbeat -e " still if I close the Terminal I am getting stopped the Beat as well

Any alternate command is there for starting and stopping in background for Linux Version Beats

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [February 8, 2021, 1:57pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/2 "2021-02-08T13:57:18Z")

</div>

Hi!

You can run it as linux service as the installation docs propose: [Metricbeat quick start: installation and configuration | Metricbeat Reference [7.10] | Elastic](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-installation-configuration.html#start)

C.

---

<div class="post-metadata">

**Author:** ![shaiksubhan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shaiksubhan](https://discuss.elastic.co/u/shaiksubhan)\
**Post date:** [February 9, 2021, 11:00am UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/3 "2021-02-09T11:00:35Z")

</div>

yes But if I start and if I close terminal Beat also stopped

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [February 9, 2021, 1:38pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/4 "2021-02-09T13:38:35Z")

</div>

`sudo service metricbeat start` should start the service and no matter what you do with the terminal it will continue running in the background as a linux service. Did you try that and service was stoped after exiting terminal?

---

<div class="post-metadata">

**Author:** ![shaiksubhan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shaiksubhan](https://discuss.elastic.co/u/shaiksubhan)\
**Post date:** [February 9, 2021, 2:09pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/5 "2021-02-09T14:09:35Z")

</div>

Yes that command is for Deb Version I know, But here I am using Linux version of Beats there Only ./metricbeat -e is there

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [February 9, 2021, 2:26pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/6 "2021-02-09T14:26:42Z")

</div>

`./metricbeat -e` is just executing the binary. Installing Metricbeat as a service, or `Deb` as you mentioned, will give you the option to run it as linux service and have the background capabilities as well as be able to configure it to start automatically on boot. Running as a service is possible on both deb based systems (ubuntu, debian) but also on rpm based (centos, fedora).

If just want to stick with the simple binary execution then just a `./metricbeat -e &` will do the trick but I wouldn't recommend that. Whatever you prefer 🙂 .

C.

---

<div class="post-metadata">

**Author:** ![shaiksubhan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shaiksubhan](https://discuss.elastic.co/u/shaiksubhan)\
**Post date:** [February 9, 2021, 2:30pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/7 "2021-02-09T14:30:25Z")

</div>

If I execute the ./metricbeat. Then If I close terminal beat is stopped So My question is that is there any way to start metricbeat as a background service for Linux version

---

<div class="post-metadata">

**Author:** ![shaiksubhan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shaiksubhan](https://discuss.elastic.co/u/shaiksubhan)\
**Post date:** [February 9, 2021, 2:32pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/8 "2021-02-09T14:32:26Z")

</div>

So You are telling that for Deb and rpm version Only it will run background as a service For LInux version just executing the binary am i right ?

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [February 9, 2021, 2:38pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/9 "2021-02-09T14:38:28Z")

</div>

Not sure that I understand what is this Linux version you are referring to? Debian, Ubuntu, Fedora and Centos are linux distributions. In this distributions you can get the binary of Metricbeat and run it directly with `./metricbeat` OR you can install Metricbeat as a service and run it as a linux service. This is the only difference, the way you want to install and operate Metricbeat execution. If you want to just get the binary and run it natively on Linux then just add `&` in the end of the command and you will run it in the background as I mentioned above. If you don't want to install via deb or rpm then you will need to define the linux service on your own so as to wrap Metricbeat's binary execution. Hope that helps.

C.

---

<div class="post-metadata">

**Author:** ![shaiksubhan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shaiksubhan](https://discuss.elastic.co/u/shaiksubhan)\
**Post date:** [February 9, 2021, 2:54pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/10 "2021-02-09T14:54:26Z")

</div>

![Screenshot from 2021-02-09 20-22-52](https://us1.discourse-cdn.com/elastic/original/3X/7/8/788eb0219203ca82ae5afc1b7aeb14b9eae5651f.png)  
I am referring this metricbeat running process.

---

<div class="post-metadata">

**Author:** ![shaiksubhan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@shaiksubhan](https://discuss.elastic.co/u/shaiksubhan)\
**Post date:** [February 9, 2021, 2:57pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/11 "2021-02-09T14:57:17Z")

</div>

![Screenshot from 2021-02-09 20-25-34](https://us1.discourse-cdn.com/elastic/original/3X/b/0/b04186e9492eb973742c6cea8688336c6836a88a.png)

if I start like this with ./packetbeat -e &

If i press enter then the service is stopped.

---

<div class="post-metadata">

**Author:** ![ChrsMark](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrsmark/32/55858_2.png) [@ChrsMark](https://discuss.elastic.co/u/ChrsMark)\
**Post date:** [February 9, 2021, 3:17pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/12 "2021-02-09T15:17:17Z")

</div>

It was exited only by hitting `enter` 🤔 ? Interesting.  
Can you try with `nohup ./metricbeat -e &`?

---

<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:** [March 9, 2021, 5:18pm UTC](https://discuss.elastic.co/t/how-to-run-metricbeat-in-background/263595/13 "2021-03-09T17:18:06Z")

</div>

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