geth工作运行程序转后台

今天查看了一下运行程序怎么转后台,然后就发现了之前写的脚本一定要进行console控制台然后在解锁coinbase,然后才手动挖矿的操作真的是太笨了,后面研究了一下,发现是可以在运行语句上进行操作的:

geth --config geth.toml --unlock "0x3b896fb3e31fc9b91921d19b8c7271d1c3af5b35" --password ./password --mine --etherbase 0 2>> ./geth.log

如上面的命令所示,只要使用--unlock和--password就能够直接解密账户,而且还不会有时间的限制

使用--mine和--etherbase就能够在启动的同时进行挖矿,--etherbase一定要指明,才知道收益矿工是谁,因为其默认为“0”,即第一个账户,设置为1则为第二个账户

然后之后你想要连接该客户端的控制台进行什么操作的时候,你就可以运行:

geth attach --datadir ./data0

--datadir指明你的geth客户端的geth.ipc在哪里,然后就能够进入控制台了

然后这样你就能够使用nohup command & 命令将程序运行到后台了

 输出都会输出到本地目录生成的nohup.out文件中

然后可以输入下面的命令来查看输出内容:

[root@1930c638109d blockchain-web]# tail -fn 50 nohup.out
Thu, 10 Jan 2019 03:42:31 GMT body-parser deprecated undefined extended: provide extended option at index.js:10:20
应用实例,访问地址为  :::8081
Thu, 10 Jan 2019 06:55:37 GMT body-parser deprecated undefined extended: provide extended option at index.js:10:20
应用实例,访问地址为  :::8081
 

然后查看此时后台运行程序的状态:

[root@1930c638109d blockchain]# ps -aux | grep "startGeth.sh"
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      4068  0.0  0.0 106140  2432 pts/0    S    03:41   0:00 /bin/sh ./startGeth.sh
root      4112  0.0  0.0 103384  2140 pts/3    S+   03:47   0:00 grep startGeth.sh
[root@1930c638109d blockchain]# ps -aux | grep "startGeth.sh"
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      4068  0.0  0.0 106140  2432 pts/0    S    03:41   0:00 /bin/sh ./startGeth.sh
root      4114  0.0  0.0 103384  2088 pts/3    S+   03:47   0:00 grep startGeth.sh
[root@1930c638109d blockchain]# jobs -l
[root@1930c638109d blockchain]# ps 4095
  PID TTY      STAT   TIME COMMAND
 4095 pts/1    Sl     0:00 node index.js 
原文地址:https://www.cnblogs.com/wanghui-garcia/p/10249198.html