18

I started monerod as a background daemon with the --detach flag.

Suppose I want to restart my computer, how do I gracefully stop the process?

Can I just kill it?

Thanks in advance.

cialu
  • 1,631
  • 12
  • 42
dpzz
  • 4,539
  • 3
  • 19
  • 45

6 Answers6

16

Run monerod exit. You can also just kill the process but you might lose the last batch of blocks that way.

Smart Kid
  • 6,563
  • 2
  • 36
  • 62
hyc
  • 4,233
  • 18
  • 21
  • 1
    Thanks. I didn't realize it was that easy … I thought it would attempt to start another process, which is not the case. Just tried monerod exit, monerod status, works great. – dpzz Sep 06 '16 at 21:53
  • 1
    For completeness: the exit command will save the blockchain and close the daemon gracefully if not running with the --detach flag. – well_then Oct 25 '16 at 17:14
  • What is the difference between stop_daemon and exit -- why do the both exist? – Jonathan Cross Aug 27 '18 at 11:56
4

When you've started monerod with the --rpc-bind-ip option (and --confirm-external-bind), you should also reference that when sending commands, such as exit (or status). For example, the following wouldn't work anymore:

$ monerod exit
Creating the logger system
Error: Couldn't connect to daemon

You'd need to do it like this instead:

$ monerod exit --rpc-bind-ip ….….….…
Creating the logger system
Stop signal sent
dpzz
  • 4,539
  • 3
  • 19
  • 45
3

As for Unix signals:

kill -TERM

Seems to also send the correct shutdown for a clean exit.

Tested on monerod 0.10.3.1 on macOS.

galoget
  • 161
  • 6
0

I know my response is a little bit too late. But I would like to suggest something for those who had encounter the same problems. The following is applicable with monero gui version 18.3.1 monerod. ( I still don't have any idea if it is applicable for other versions...)

Step 1: In the Log Tab under settings of your monero gui, you will see a textbox just type "save" and wait for the confirmation that the blockchain has been saved.

Step 2: After the blockchain has been saved, just type next "stop_daemon" then wait for confirmation. Make sure to check on Task Manager under Processes if monerod isn't running.

After that you could close the monero gui knowing that the blockchain isn't corrupted and saved properly. You might also want to create a backup until the blockchain isn't fully syncronized.

Just copy data.mdb under C:\ProgramData\bitmonero\lmdb If you can not see ProgramData under C: under Organize>Folder and Search Options>View>Check "Show hidden files, folders and drives"...

I hope these would help... Noob!!!

0

Bring monerod process that is running in the background into the foreground and then type exit.

skaht
  • 1,576
  • 11
  • 19
0

As of version 0.10.3.1, dpzz's answer doesn't appear to work. Specifically, if you start the daemon with --rpc-bind-ip, referencing that in the commands to send to the daemon doesn't successfully locate the daemon.

galoget
  • 161
  • 6
puzzler
  • 263
  • 1
  • 9
  • 2
    Still works for me: monerod --rpc-bind-ip ….….….… --confirm-external-bind --detach followed by monerod --rpc-bind-ip ….….….… exit. File an issue on GitHub please if the problem persists. Also, you should comment on an answer here, rather than post a comment as an answer. – dpzz Aug 12 '17 at 08:16