<p>I am answering my own question for those who run into the same situation and for the sake of knowledge sharing.</p>

<p>YES you can mine on a regtest network. The difficulty of mining on regtest is extremely low that you miner program will just mine block after block almost instantly.</p>

<p>The reason why cgminer was not mining is because it is for GPU mining and there was no GPU on my machine and I could not find a way to mine with CPU using cgminer.</p>

<p>So I switched to another miner: cpuminer, which mines with cpu and it worked:)</p>

CC BY-SA 4.0
2018-07-19T09:06:59.657Z
2018-07-19T09:06:59.657Z
3tbraden
<p>You can build your miner with a bash command:</p>

<pre><code>$ while true; do bitcoin-cli -regtest generate 1; sleep 300; done
</code></pre>

<p>You'l get a block every 5'. If you want a better simulation of mainnet you could use a rndom <code>sleep</code></p>

CC BY-SA 4.0
2018-11-08T13:52:21.043Z
oh yes I discovered later this is probably a more efficient way to simulate actual mining on regtest than using a mining program
3tbraden
CC BY-SA 4.0
2018-10-27T10:45:01.407Z
2018-10-27T10:45:01.407Z
the9ull
<p>I wonder if I can do mining with Bitcoin-0.16.1 in regtest mode, just for simulating mainnet situation where there are new blocks coming in constantly.</p>

<p>I am aware that I can use <code>generate</code> to generate blocks almost instantly after every transaction and thus confirm the transaction. But can I use a miner program to automate that process and simulate better the real-world situation, i.e. new block coming in constantly in small number?</p>

<p>I have tried cgminer connecting to my regtest solo mining but it does not seem to mine anything, it just sits there and hash rate is always 0. Any advice on how I can mine on regtest or should I set up some automated scripts to call <code>generate</code> from time to time?</p>

<bitcoind><cgminer><ubuntu><regtest>
Bitcoin regtest mining
3tbraden
# Bitcoin regtest mining

(Asked by: username_0 on 2018-07-19)

I wonder if I can do mining with Bitcoin-0.16.1 in regtest mode, just for simulating mainnet situation where there are new blocks coming in constantly.

I am aware that I can use `generate` to generate blocks almost instantly after every transaction and thus confirm the transaction. But can I use a miner program to automate that process and simulate better the real-world situation, i.e. new block coming in constantly in small number?

I have tried cgminer connecting to my regtest solo mining but it does not seem to mine anything, it just sits there and hash rate is always 0. Any advice on how I can mine on regtest or should I set up some automated scripts to call `generate` from time to time?

**Tags:** bitcoind, cgminer, ubuntu, regtest


---

## 2 answers

### Answer by username_1 on 2018-10-27. Score: 5 | Accepted answer

You can build your miner with a bash command:

```
$ while true; do bitcoin-cli -regtest generate 1; sleep 300; done

```

You'l get a block every 5'. If you want a better simulation of mainnet you could use a rndom `sleep`

> **Comments:**
> **username_0**: oh yes I discovered later this is probably a more efficient way to simulate actual mining on regtest than using a mining program  

---

### Answer by username_0 on 2018-07-19. Score: 3

I am answering my own question for those who run into the same situation and for the sake of knowledge sharing.

YES you can mine on a regtest network. The difficulty of mining on regtest is extremely low that you miner program will just mine block after block almost instantly.

The reason why cgminer was not mining is because it is for GPU mining and there was no GPU on my machine and I could not find a way to mine with CPU using cgminer.

So I switched to another miner: cpuminer, which mines with cpu and it worked:)


---

