Anyway to automatically restart ethminer when it crashes?

adasebadaseb Member Posts: 1,043 ✭✭✭
Every few hours or few days, ethminer stops because some GPU crashed. Was wondering if there is anyway to get it to automatically restart without doing it manually. Like a watch dog program. This is for Windows 7.
«1

Comments

  • happytreefriendshappytreefriends Member Posts: 537 ✭✭✭
    I don't think so, but you could have it do an automatic restart set at a time frame. I do that with other miner software that I know crashes every few hours. I just have it shut the instance off and start a new one every hour. Adds a few seconds of lost hashing power, but better than being down 1/2 a day if I dont' notice it.
  • adasebadaseb Member Posts: 1,043 ✭✭✭
    Ok sounds good, how do you enable that?
  • happytreefriendshappytreefriends Member Posts: 537 ✭✭✭
    thantham.. That is a VERY nice and clean way to do that. KUDOS!!! B)
  • adasebadaseb Member Posts: 1,043 ✭✭✭
    Is that for Windows ? Or linux?
  • happytreefriendshappytreefriends Member Posts: 537 ✭✭✭
    Windows. It's a .bat file.
  • JabulonJabulon Member Posts: 45
    edited February 2016
    Very useful. If someone can create a corresponding crontab script for linux, that would be great. One of my rigs, for a reason I haven't been able to diagnose, starts getting a recurring error after running for 30-90 mins with no problems:
    Dynamic exception type: jsonrpc::JsonRpcException
    std::exception::what: Exception -32003 : Client connector error: libcurl error: 28 -> Operation timed out
    It continues hashing and submitting shares intermittently, but I lose about half my share-rate and need to restart.

    Edit: for whatever reason, it seems to work better to restart the whole system, not just the miner. And, mysteriously, leaving the system off for a couple hours seems to help. If restarted immediately, the errors begin again quickly. Would love to understand that too.
  • mindlessmindless Member Posts: 6
    Actually, adding it as a process under supervisord might be best for Linux. It will restart in case the process is dead. Dirtier solution, check out monit.
  • AkarabzieAkarabzie Member Posts: 5
    Dude, Thank you so much. My scripting skills are not the best and I have a mining rig I through together from an old AMD build (Athlon X2 days) and it crashed about every 12 hours or less. This will be a lifesaver tonight when i set the batch file up. Major kudos my friend. I'll probably put this on my main rig as well.
  • DPS50DPS50 Member Posts: 79
  • MrOkgsMrOkgs Member Posts: 8
    thanhtam said:

    Restart miner after 9000s
    @echo off echo ------------------------------------------------------------------- echo Simple script to restart your miner software after a period of time echo ------------------------------------------------------------------- echo: set executable=ethminer.exe set commandline= -F http://pooladdress -G set runforseconds=9000 set restartinseconds=10 set /a counter=0 timeout 15 setx GPU_MAX_ALLOC_PERCENT 100 setx GPU_USE_SYNC_OBJECTS 1 setx GPU_MAX_HEAP_SIZE 100 :start start "ETHMiner" %executable% %commandline% echo: echo The software will run for %runforseconds% seconds timeout %runforseconds% taskkill /f /im %executable% echo: echo Restarting the software in %restartinseconds% seconds (%counter%) timeout %restartinseconds% set /a counter+=1 echo: echo: goto start

    why didn't i think of this! cudos!
  • ButtsAusButtsAus Member Posts: 4
    Give the man some ETH!
  • hasherhasher Member Posts: 642 ✭✭✭
    You know, the much easier way would be to use claymore's miner - it has auto restart when a GPU stops responding :)
  • MyNameMyName Member Posts: 1
    You can also end the control .bat file with its file name. The example below creates a loop where whenever the ethminer process fails it restarts the batch file that starts ethminer again.

    Control file name: myfile.bat

    Contains
    --------
    Ethminer -f ..... (your current configuration)
    myfile
  • ssdaytonassdaytona Member Posts: 12
    does ethminer come with an auto restart feature yet?

    I'm going away for 2 weeks and need to be sure that my miner will reboot if it crashes.
  • FirstnameBeauFirstnameBeau Member Posts: 29
    So, I have 2 batch files that I place in my startup folder. 1 checks to make sure the miner is active every 30 seconds - or reboot - the other checks to make sure there are no failed GPU's or reboot. I've been using these scripts for the last few weeks without a single miss.

    It also logs to a shutdown.txt so you can see exactly what it triggered on and what time.

    Let me know if anyone is interested.
  • ssdaytonassdaytona Member Posts: 12
    I would be very interested.


    What about if windows freezes? I.e. Unable to remote login and only thing that will help is a hard reboot
  • FirstnameBeauFirstnameBeau Member Posts: 29
    It would also detect that as well... since, if windows stops responding, ethminer will stop responding.

    And if necessary, I could put in a loop that checks RDP connectivity... once it's no longer responsive, reboot.. Hmmmm. Okay, give me a bit. I've got 4 kids to watch today but I'll see what I can whip up.
  • FirstnameBeauFirstnameBeau Member Posts: 29
    edited August 2017
    Here's the script I've been using thus far. It will detect failed GPU's or even a crash/hung miner and reboot accordingly. I place it in my startup folder. The script will start the miner - so you only need to run this single script.

    Only thing I haven't had time to do was add dynamic path's, so you will need to do 2 things first:

    1) Modify the script and replace "C:\Users\jexus\Desktop\CLMR\" with whatever your path to your local claymore folder.

    2) I'm not sure if the script will create one if it doesn't exist, so create a .txt file in your CLMR folder called shutdowns.txt. This will be the log when shutdowns occur.

    I've only ever used it on my machine, Windows 7 64 bit so let me know if you run into any issues.
    Also, I plan expanding on this when I have time so if you have any more suggestions, or run into any bugs or problem please let me know.

  • ssdaytonassdaytona Member Posts: 12
    Thanks! Will check it out tonight
  • FirstnameBeauFirstnameBeau Member Posts: 29
  • ssdaytonassdaytona Member Posts: 12
    I haven't tried it yet. got tied up with work. will let you know.
  • samjankussamjankus Member Posts: 100
    edited August 2017

    So, I have 2 batch files that I place in my startup folder. 1 checks to make sure the miner is active every 30 seconds - or reboot - the other checks to make sure there are no failed GPU's or reboot. I've been using these scripts for the last few weeks without a single miss.

    It also logs to a shutdown.txt so you can see exactly what it triggered on and what time.

    Let me know if anyone is interested.

    Dumb question... when Windows 10 restarts I have to login in order to start any process (miner). I'm guessing there's a way to start the miner without logging in?

    (I realize you're running Win 7, but maybe the same for both?),

    Would you please share?

  • FirstnameBeauFirstnameBeau Member Posts: 29
    Hmmmmm, maybe, but I think it would leave your system vulnerable, which defeats the purpose of a login. Basically, cmd.exe has to run under some context - a username and a parent process. If we didn't use your user account we would be using someone elses - worst case scenario, we would use System, which would leave your computer extremely vulnerable to privleged code execution.

    Your best bet is to turn off the logging in feature (simple user switching), otherwise the work around with circumvent the login security measure anyway...

    $.02
  • MLN84MLN84 Member Posts: 48
    • Press Ctrl+R (Run) and type: "netplwiz" (without ") on Windows 10.
    • Configure it for not needing login and password. Use an account without admin rights.
    • Put your bat files in autostart (Ctrl+R; "shell:startup") and go.
    As pointed out, beware of security risks.
  • samjankussamjankus Member Posts: 100
    MLN84 said:

    • Press Ctrl+R (Run) and type: "netplwiz" (without ") on Windows 10.
    • Configure it for not needing login and password. Use an account without admin rights.
    • Put your bat files in autostart (Ctrl+R; "shell:startup") and go.
    As pointed out, beware of security risks.
    Great... thanks so much!
  • MLN84MLN84 Member Posts: 48
    No problem. Just one correction, it should be the WINDOWS key, not Ctrl to open "Run". Sorry.
  • EtherminerJayEtherminerJay Member Posts: 157
    @FirstnameBeau

    Thank you for your input I've been having the same issue as well as some others.

    Which is this issue from claymore miner Miner thread hangs, need to restart miner!


    I've added a few lines to the script you uploaded and put them in bold, do you think this will work for the issue I am having.

    any extra input from you on this would be greatly appreciated!


    @echo off

    :start
    SET loopnum=0

    echo Initializing...
    cd "C:\Users\Jon\Desktop\miner\
    START start_only_eth.bat
    goto run

    :run
    timeout 15
    SET /A loopnum=loopnum+1
    echo Script has completed %loopnum% loops.
    @echo off

    for /F "tokens=*" %%f in ('dir /od /b "C:\Users\Jon\Desktop\miner\start_only_eth.bat*"') do set _lastFile=%%f
    echo Parsing for errors...

    findstr /I /C:"CUDA error" "C:\Users\Jon\Desktop\miner\start_only_eth.bat*.txtstart_only_eth.bat\%_lastFile%"
    if %ERRORLEVEL% == 0 (
    echo CUDA Errors found>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    goto :errorzero
    ) ELSE (
    goto :nex1
    )
    :nex1
    findstr /I /C:"failed GPU" "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\%_lastFile%"
    if %ERRORLEVEL% == 0 (
    echo Failed GPU string found>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    goto :errorzero
    ) ELSE (
    goto :nex2
    )
    :nex2
    findstr /I /C:"unspecified launch failure" "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\%_lastFile%"
    if %ERRORLEVEL% == 0 (
    echo Unspecified Launch Failure string found>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    goto :errorzero
    ) ELSE (
    goto :nex3
    )
    :nex3
    findstr /I /C:"Miner thread hangs, need to restart miner!" "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\%_lastFile%"
    if %ERRORLEVEL% == 0 (
    echo Miner thread hangs, need to restart miner! string found>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    goto :errorzero
    ) ELSE (
    goto :run2ME

    )


    :noerrors
    echo No issues detected. Resume mining...
    goto run


    :errorzero
    echo Error(s) found. Check shutdown.txt to see what was logged.
    echo Rebooting now...
    timeout 3
    echo %DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    echo %time%>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    echo "loopnumber: " %loopnum%>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    shutdown /r /t 3


    @echo off
    timeout 15

    :run2ME
    for /F "tokens=*" %%f in ('dir /od /b "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\*.txt"') do set _lastFile=%%f
    for /f %%i in ('find /v /c "" ^< C:\Users\Jon\Desktop\miner\start_only_eth.bat*\%_lastFile%') do set /a lines=%%i
    timeout 15

    for /f %%I in ('find /v /c "" ^< C:\Users\Jon\Desktop\miner\start_only_eth.bat*\%_lastFile%') do set /a lines1=%%I
    if %lines% == %lines1% (
    echo Looks like miner may have crashed, checking again ...
    goto :nex5
    ) ELSE (
    echo All is well.
    goto :noerrors
    )

    :nex5
    timeout 10
    for /f %%I in ('find /v /c "" ^< C:\Users\Jon\Desktop\miner\start_only_eth.bat*\%_lastFile%') do set /a lines2=%%I
    if %lines1% == %lines2% (
    echo Miner has died of dysentery ...
    echo Loggin into shutdowns.txt - Check for details as to why the shutdown.
    echo Line count match %lines% , %lines1% , %lines2%>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    echo %DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    echo %time%>> "C:\Users\Jon\Desktop\miner\start_only_eth.bat*\shutdowns.txt"
    echo Shutting down now ...
    shutdown /r /t 3
    pause
    ) ELSE (
    echo Close but all is well.
    timeout 3
    goto :noerrors
    )













  • ssdaytonassdaytona Member Posts: 12
    I'm just looking at the script now.


    does this work for ethminer or only claymore?
  • FirstnameBeauFirstnameBeau Member Posts: 29
    This is claymore. I could make one for ethMiner should I find the time and desire.. :)
Sign In or Register to comment.