Set Daemon For Geth
As sometimes , geth process will be killed by VPS system ,so we need to set daemon for geth processed.It's easy and suitable to set daemon in Linux OS, you may use supervisor,(http://supervisord.org).
We assume the source code go-etherzero is in directory /root amd geth is running by root user.
Write daemon.sh
CAUTION: you must replace the words 'your address' to your own rewards address.
cat << EOF > /root/daemon.sh
#!/bin/bash
source /etc/profile
source ~/.bashrc
jspid="ps aux | grep maxpeers | grep -v grep | awk '{print $2}'"
echo $jspid
if [ -z "\$jspid" ] ; then
echo $jspid
nohup ~/go-etherzero/build/bin/geth --maxpeers 50 --syncmode fast --masternode --etherbase "your address" > output.log 2>&1 &
else
echo "run normaly"
fi
EOFGenerating the miner.sh
echo -e " ~/go-etherzero/build/bin/geth attach --exec 'miner.start()' " > /root/miner.sh && chmod +x /root/miner.shset daemon.sh and miner.sh for execute miner start each minute
( crontab -l | { cat; echo "*/1 * * * * /bin/bash /root/daemon.sh & "; } ) | crontab - && ( crontab -l | { cat; echo "*/1 * * * * /bin/bash /root/miner.sh & "; } ) | crontab -As the crontab is running by every minute ,so we need to set another shell script for each seconds to monitor the process,
Generating the second.sh.
Add second.sh instead of daemon.sh, to monitor geth process every one second
Last updated
Was this helpful?