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 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM