I've been having issues with my eth miner, nsfminer, crashing on me when I leave it on at night. Sometimes this occurs after 2-8 hours of mining, while sometimes it doesn't occur at all. It usually exits with a message that I can't recall off the top of my head. I did some searching on my own and threw together a bash script using an until loop and was wondering if this should work in theory. Usually I would just test it on my own because that's the best way to learn, but considering I may have to wait 8 hours for a crash or it may not even crash at all for several days, I'd like to know if this script will work before I potentially lose $5-10 of profit. It seems to work just fine when I run it, but I don't know if the autorespawn works as I've yet to leave it running for long enough to see if it crashes.

until echo PASSWORD | sudo -S ./nsfminer --cu-block 256 --cu-streams 4 -P stratum+tcp://USERNAME:PWDARGS@domain:PORT; do
    echo "nsfminer crashed with exit code $?" >&2
    sleep 1

I understand the security implications involved in passing a root password via a bash script, but it's the only way to get the miner to work as it requires root privileges and I have the system partitioned in a way that the installation I use for crypto mining only has mining stuff and i3 installed on it and doesn't have any passwords stored in plaintext in any files. It's otherwise a minimal ubuntu install with most of the applications stripped away. I intend in the future to perhaps go the debian stable route, or maybe start from ubuntu server which I have tried before but I just haven't had the time to get everything working with nvidia drivers being a pain and all. Thanks for any help from anyone more knowledgeable than me.

  • I think the script looks okay, but you'll want to check the condition where nsfminer exits with a zero status code and terminates the loop. As an alternative, have you considered writing a systemd service? systemd can watch the process and handle restarts for you and it can also take care of the root requirement. – Haxiel Jun 13 at 3:37
  • 1
    sudo visudo gives you a way to avoid passing in the password, by allowing the user/group to run this specific command. – l0b0 Jun 13 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.