Bitcoin regtest mining 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?
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