2

So I run

geth --testnet --rpc --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,web3" console

But when I exit out of putty geth stops.

I tried to add:

--daemon

But it didn't work.

How do I keep geth running?

Marc Alexander
  • 358
  • 4
  • 18
  • 2
    Hi there. This is a general Linux question, as opposed to anything specific to Ethereum, so I'm going to suggest it be closed as off-topic. The answer is to use screen, or a similar utility. – Richard Horrocks Jul 12 '17 at 23:07
  • 2
    For example: https://superuser.com/questions/96660/how-can-i-keep-a-process-alive-after-closing-the-putty-session – Richard Horrocks Jul 12 '17 at 23:08
  • 2
    IMHO this question can be useful to have, along with an answer like @RichardHorrocks comment. If it gets closed, it might not be as searchable. But it's up to the community if it wants to close this. – eth Jul 14 '17 at 19:56
  • Happy to leave this open if people think it'll be useful. – Richard Horrocks Jul 14 '17 at 21:19
  • See also: https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session – Lee May 18 '19 at 15:07

1 Answers1

2

When you close your Putty session it delivers a hang-up signal (SIGHUP) to the Geth daemon, which causes it to close. The Putty session is Geth's parent process, regardless of using the --daemon option, so its children will die with it.

Note that I think some care has to be taken when Geth closes in this way. I don't think Geth has proper signal handlers for SIGHUP which could mean that things aren't left in a clean state. (e.g. If you're syncing block data, then corruption of the data is a possible outcome.)

See the accepted answer to this thread: Is it safe to kill geth with SIGTERM?

To prevent the daemon being killed in this way, you have a few options. The two that I've used in the past (for things unrelated to Ethereum) are either to redirect the SIGHUP so it isn't delivered to the process, or use a utility like screen (which I think is easier).

These threads (1, 2) from other Stack Exchange boards have more details.

Richard Horrocks
  • 37,835
  • 13
  • 87
  • 144