Skip to content

Instantly share code, notes, and snippets.

@jaidhyani
Last active September 19, 2022 08:27
Show Gist options
  • Save jaidhyani/71476669c43e79887db93caadb238a92 to your computer and use it in GitHub Desktop.
Save jaidhyani/71476669c43e79887db93caadb238a92 to your computer and use it in GitHub Desktop.
Ethereum mining script (for use with systemd)
#!/bin/bash
#requirements
# -nc
# -genoil's ethminer (https://github.com/Genoil/cpp-ethereum)
# a CUDA-compatable GPU
# this is obviously hacky and gross, uses hardcoded paths to personal dirs, etc
# but should be easily adaptable
ethminer="/home/jai/cpp-ethereum/build/ethminer/ethminer"
addr="0x000000000000000000000000000" #REPLACE WITH YOUR ETHEREUM ADDRESS
$ethminer -v 1 --farm-recheck 200 -U -S eth-us-west1.nanopool.org:9999 -O $addr.`hostname -s` &
@jaidhyani
Copy link
Author

jaidhyani commented Jul 19, 2017

Wrote this to have my machine instantly go into ethmining when it boots, which should net about $70/month right now. I stop the miner whenever I want to do any work with the GPU myself, or when I boot into Windows for gaming. When I'm done, I can just restart the service or reboot the machine and it'll go right back into mining. Also logs to seashells, so I can monitor it from wherever if I want.

Here's the service file at /lib/systemd/system/ethmine.service:

[Unit]
Description=Job that runs ethminer

[Service]
Type=simple
PIDFile=/var/tmp/ethminer.pid
ExecStart=/home/jai/bin/ethmine.sh

[Install]
WantedBy=multi-user.target

Run sudo systemctl enable ethmine.service to enable mining on boot

sudo service ethmine stop and sudo service ethmine start to manually control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment