Go-ethereum: How to run the geth client in the background ?

Created on 13 Mar 2018  路  9Comments  路  Source: ethereum/go-ethereum

Hi,
I know the geth client is started in the console as follows(I use private network):
./geth --identity ... --networkid 100000 console

The problem is that once the console is closed, the geth process is terminated too. This isn't what i wanted, what i hope is that the geth can run in the background such as Tomcat, Nginx, etc.

Does anyone have a good idea?
Thank a lot.

Most helpful comment

Use screen or tmux. screen starts a new bash session, there you can start geth. Then hit ctrl-d to detach, and now you can even log out from the server if you want. Later on, you can do screen -ls to view screen sessions, and screen -r xxx to resume one of them.
tmux is a bit newer and shinier than screen, YMMV

All 9 comments

Put it into the background like any other Linux process: nohup ./geth --identity ... --networkid 100000 &

Note, you need to omit the console, because nohup closes the input stream and the console terminates if its input it closed.

@karalabe
Yes, I tried to use nohup at first, but it didn't work, According to your advice, I omitted the parameter console, worked fine.
Many thanks!

Apologies for bringing this back up, but i need this a starting point.

How can I now go back to it? All linux solutions i found so far have not allowed me to interact with the node.
Why?

I want to see the interaction occuring and
I want to shut down geth gracefully

You can start geth in the background via nohup geth --all-your-flags.
You can attach to it via a console via geth attach geth.ipc-path-in-your-datadir.
You can gracefully terminate geth by sending the first process a sigint kill -SIGINT first-geth-pid.

understood, but how can go back to the process before killing it? if I attach to geth, I will not see the original start with contracts submitted etc

Use screen or tmux. screen starts a new bash session, there you can start geth. Then hit ctrl-d to detach, and now you can even log out from the server if you want. Later on, you can do screen -ls to view screen sessions, and screen -r xxx to resume one of them.
tmux is a bit newer and shinier than screen, YMMV

thanks everyone

How come nohup is necessary rather than just geth &?

$ geth &
[1] 11721

$ jobs
[1]+  Stopped                 geth
Was this page helpful?
0 / 5 - 0 ratings

Related issues

keitaj picture keitaj  路  3Comments

ysqi picture ysqi  路  3Comments

bgrieder picture bgrieder  路  3Comments

362228416 picture 362228416  路  3Comments

vogelito picture vogelito  路  3Comments