<p>I think understanding the hierarchy of how software works would be helpful here. You're interacting with the software, Bitcoin Core. While you're experiencing either a GUI wallet and network stats or interacting with the bitcoin-cli, your OS is experiencing bitcoind, the bitcoin <code>daemon</code>. It is--in the scope of this scenario--the fundamental piece of your bitcoin node or wallet.</p>

<p>Wikipedia introduces Daemons nicely:</p>

<blockquote>
  <p>a daemon (/ˈdiːmən/ or /ˈdeɪmən/)[1] is a computer program that runs
  as a background process, rather than being under the direct control of
  an interactive user</p>
</blockquote>

<p>Spooky. In Unix systems specifically, it is a daemon if</p>

<blockquote>
  <p>the process is started from the command line <strong>or</strong> from a startup
  script such as an init script</p>
</blockquote>

<p>The init script in this case is the bitcoin.conf file. If it initiates the daemon, it is doing it's thing running in the background. All the core processes that are required to run the underlying code and for a GUI and command line to be used on top of that are active, silently. </p>

<p>Any interaction that you have with the software requires the daemon to be running. If it's not already, it will start it. Once running, you can change the bitcoin.conf file or variables dynamically through the command line as you see fit during your session.</p>

<p>Then when you're done, whatever state the bitcoin.conf file is in when the computer or daemon begin will determine it's behavior.</p>

<p>If you want bitcoin running in the background always, ensure that the config file runs the daemon on startup or that you start it yourself if it's not running. It is redundant to do both.</p>

CC BY-SA 4.0
2019-12-24T09:45:42.840Z
2019-12-24T09:45:42.840Z
jon.bray.eth
<blockquote>
  <p>When running bitcoind from a systemd service, as in <a href="https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service" rel="noreferrer">https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service</a>, what is the role of the -daemon flag? </p>
</blockquote>

<p><code>-daemon</code> starts bitcoind in the background as a daemon. So if you run <code>bitcoind -daemon</code> in the terminal, the program will exit immediately but bitcoind is still running in the background. Without <code>-daemon</code>, you will see that bitcoind appears to hang in the terminal, but that just means it is running. If you stop the command, then bitcoind will stop as well.</p>

<blockquote>
  <p>If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting </p>
</blockquote>

<p>Yes. This applies for all command line options.</p>

CC BY-SA 3.0
2018-04-18T21:48:45.923Z
Yes, I see that the terminal seems 'occupied' or 'hanging' when the daemon setting is turned off. But my question was not about starting the daemon in terminal, but in a systemd service. In this case what is the consequence of running with the daemon setting turned on, or going instead Type=simple and no daemon does the job correctly also?
user2066480
CC BY-SA 3.0
2018-04-18T22:18:06.107Z
As I explained in your other question about this, you cannot use Type=simple without -daemon. Systemd will not work with that.
Ava Chow
CC BY-SA 3.0
2018-04-18T22:37:04.510Z
In the other question about forking vs simple, you made a case against using Type=simple together with daemon=1. In my comment above I was asking for Type=simple together with daemon=0.
user2066480
CC BY-SA 3.0
2018-04-18T23:01:56.050Z
I see. There is no difference between using Type=simple and daemon=0 and using Type=forking and daemon=1.
Ava Chow
CC BY-SA 4.0
2018-12-20T23:12:52.467Z
From my experience `Type=simple` and `daemon=1` in btc conf file, makes daemon shotdown just after start with `systemctl start`
Pawel Cioch
CC BY-SA 4.0
2018-12-20T23:20:12.450Z
I just tested Type=forking is needed when daemon=1 flag is used
Pawel Cioch
CC BY-SA 3.0
2018-04-18T21:18:08.850Z
2018-04-18T21:18:08.850Z
Ava Chow
<ol>
<li>When running bitcoind from a systemd service, as in <a href="https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service" rel="noreferrer">https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service</a>, what is the role of the -daemon flag?</li>
</ol>

<p>Basically I'm asking what does -daemon do in a situation where bitcoind is run as service, and not as a wallet. And what happens if -daemon is not used -> in a systemd service file.</p>

<ol start="2">
<li>If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting </li>
</ol>

<bitcoind>
bitcoind daemon mode
user2066480
# bitcoind daemon mode

(Asked by: username_0 on 2018-04-18)

1. When running bitcoind from a systemd service, as in <https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service>, what is the role of the -daemon flag?

Basically I'm asking what does -daemon do in a situation where bitcoind is run as service, and not as a wallet. And what happens if -daemon is not used -> in a systemd service file.

2. If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting

**Tags:** bitcoind


---

## 2 answers

### Answer by username_2 on 2018-04-18. Score: 6 | Accepted answer

> When running bitcoind from a systemd service, as in <https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service>, what is the role of the -daemon flag?

`-daemon` starts bitcoind in the background as a daemon. So if you run `bitcoind -daemon` in the terminal, the program will exit immediately but bitcoind is still running in the background. Without `-daemon`, you will see that bitcoind appears to hang in the terminal, but that just means it is running. If you stop the command, then bitcoind will stop as well.

> If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting

Yes. This applies for all command line options.

> **Comments:**
> **username_0**: Yes, I see that the terminal seems 'occupied' or 'hanging' when the daemon setting is turned off. But my question was not about starting the daemon in terminal, but in a systemd service. In this case what is the consequence of running with the daemon setting turned on, or going instead Type=simple and no daemon does the job correctly also?  
> **username_2**: As I explained in your other question about this, you cannot use Type=simple without -daemon. Systemd will not work with that.  
> **username_0**: In the other question about forking vs simple, you made a case against using Type=simple together with daemon=1. In my comment above I was asking for Type=simple together with daemon=0.  
> **username_2**: I see. There is no difference between using Type=simple and daemon=0 and using Type=forking and daemon=1.  
> **username_3**: From my experience `Type=simple` and `daemon=1` in btc conf file, makes daemon shotdown just after start with `systemctl start`  
> **username_3**: I just tested Type=forking is needed when daemon=1 flag is used  

---

### Answer by username_1 on 2019-12-24. Score: 1

I think understanding the hierarchy of how software works would be helpful here. You're interacting with the software, Bitcoin Core. While you're experiencing either a GUI wallet and network stats or interacting with the bitcoin-cli, your OS is experiencing bitcoind, the bitcoin `daemon`. It is--in the scope of this scenario--the fundamental piece of your bitcoin node or wallet.

Wikipedia introduces Daemons nicely:

> a daemon (/ˈdiːmən/ or /ˈdeɪmən/)[1] is a computer program that runs
> as a background process, rather than being under the direct control of
> an interactive user

Spooky. In Unix systems specifically, it is a daemon if

> the process is started from the command line **or** from a startup
> script such as an init script

The init script in this case is the bitcoin.conf file. If it initiates the daemon, it is doing it's thing running in the background. All the core processes that are required to run the underlying code and for a GUI and command line to be used on top of that are active, silently.

Any interaction that you have with the software requires the daemon to be running. If it's not already, it will start it. Once running, you can change the bitcoin.conf file or variables dynamically through the command line as you see fit during your session.

Then when you're done, whatever state the bitcoin.conf file is in when the computer or daemon begin will determine it's behavior.

If you want bitcoin running in the background always, ensure that the config file runs the daemon on startup or that you start it yourself if it's not running. It is redundant to do both.


---

