5

I am trying to mine Ether on an AWS spot instances. However I came across two problems.

  1. AWS spot instances aren't persistent, meaning if the instance gets terminated the data inside will be gone.
  2. Geth and ethminer need to be run immediately after startup because you don't want to be paying attention when an instance starts or gets terminated.

Regarding the first problem I followed the instructions from this question on serverfault and now I can make spot instances somewhat persistent, any improvement of this method is welcome.

So this question is focused on the second obstacle. How can I make Geth and ethminer run from from startup, that means every time a spot instance becomes available

What I've done so far is trying to run a shell script at startup by including this on /etc/init.d/ with the following contents:

#!/bin/sh
#NOTE: tmux is a tool similar to screen
#Create a tmux season for geth
tmux new-session -d -s Gethtest 
#Create a tmux season for Ethminer
tmux new-session -d -s EthminerTest

#Execute the commands in tmux
#Geth (this starts geth)
tmux send-keys -t Gethtest 'geth --rpc console' C-m
#Make a short pause to let geth sync with the main network
sleep 90
#Ethminer (this starts ethminer)
tmux send-keys -t EthminerTest 'ethminer -G --opencl-device 0' C-m

This script was inspired by this answer posted on stackoverflow which includes more details. Typing the same commands in command line works as expected (first begin Geth and let it synchronize and then start ethminer each within a tmux session). But making it run alone at startup doesn't work as expected, and that means: the script doesn't start neither Geth nor ethminer automatically at startup.

Any help regarding how to simplify, fix and/or improve any of both problems is welcome. Suggesting alternative methods are welcome too.

2
  • 3
    This is a bit vague... Could you try making it more of a specific question? Also, what happens when you run the script on startup? Does it work, not work, have issues, etc... Commented Jan 22, 2016 at 2:04
  • The question has been edited
    – wacax
    Commented Jan 22, 2016 at 15:52

1 Answer 1

1

Can you please try to run the script as root? (As that is what it will run as when executed on bootup.) Also keep in mind that you might not have any environment variables (or even a path) set when its run, so you'll likely want to test your script with all of these conditions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.