It Is All About BTC, LTC, ETH, DOGE, KAS mining as well as other alternative crypto currencies
There were some people asking for a simple solution to automate the process of restarting a miner software every few hours in order to be sure that it is working fine under Windows OS. The below Batch file code example offers a simple and easy way to do that and it uses sandor’s fork of cpuminer for Gridseed Scrypt ASICs as an example. You need to set the parameters based on the miner and command line you use as well as the time after which the miner process will be killed (default 4 hours), then the script will wait for 10 seconds and start the miner again. There is also a counter to show you the number of restarts that have been executed since you’ve started the Batch script.
@echo off
echo -------------------------------------------------------------------
echo Simple script to restart your miner software after a period of time
echo -------------------------------------------------------------------
echo:
set executable=minerd.exe
set commandline=--freq=1150 --gc3355=\\.\COM1 --url=stratum+tcp://eu2.multipool.us:7777 --userpass=yourworker.1:password
set runforseconds=14400
set restartinseconds=10
set /a counter=0
:start
start "Miner Window" %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
In order to use the code above you just have to copy it and save as a .BAT file as well as to modify some of the variables as per your needs and requirements and then run it. Do note that you will get two program windows, one that will have the Batch script running and another for the miner software. You should not close the windows with the script running as this will stop the execution of the script immediately and the miner software will not be restarted anymore.
21 Responses to Simple Script to Restart your Miner Software After a Given Period of Time
Will
June 20th, 2014 at 11:13
I was having issues on windows with the blades. One blade after an hr or two will drop then the other will follow, the software still runs and gets work etc but blades dish out nothing, no hw errors even… I added –gc3355-timeout=120 to the bat file and so far 3 days with no messing about…… I believe it restarts the miner if no share has been submitted for over 120 seconds.. you can change the settings as desired. Mixed with the above code from the blog, happy days :)
Charlie
June 20th, 2014 at 14:14
could this work for other mining programs as well. Specifically cudaminer?
admin
June 20th, 2014 at 15:45
Charlie, it can work for any program, you just have to set the name of the executable file and the command line options and you are ready to go.
BountyBob
June 20th, 2014 at 18:31
Hi, thanks for that script :)
i’m having a problem on cudamier/ccminer: the miner process is not killed after the countdown for some reason (i then have multiple processes)
here are the only modifications i did on ccminer:
set executable=ccminer30.exe
set commandline=-a x11 -o stratum+tcp://drkpool.com:3333 -u [myUserName].1 -p x
same with cudaminer:
set executable=cudaminer
set commandline=-a keccak -i 1 -l K10x28 -C 1 -m 1 -H 1 --url stratum+tcp://erebor.dwarfpool.com:3339 -u [myUserName].1 -p x
i’m showing those 2 command lines that work on their own of course ([myUserName] replaced by the right one)
admin
June 21st, 2014 at 00:12
BountyBob, make sure you set the full executable file name, including the .exe
Just tested the script with ccminer and it works just fine here.
BountyBob
June 21st, 2014 at 14:28
i checked but rather than “SUCCESS: The process “ccminer.exe” has been terminated”
i get an “ERROR: Not enough storage is available to complete this operation.”
it might be my antivirus preventing the script to kill another process i use comodo on win7 64
i’ll figure it out, thanks anyways admin :p
admin
June 21st, 2014 at 15:26
Could be, it is a strange error message that you are getting for sure.
BountyBob
June 22nd, 2014 at 01:50
all right after a few more tests i just had the confirmation: the “taskkill” command is indeed prevented by some antivirus/firewall without telling you or sending you feedback … it’s like a silent sandbox default mode
How to test is you are in this situation?
make a “restartScriptTest.bat” with your settings and “runforseconds=10” and check if the first “Miner Window” is killed before a second one pops
How to fix ?
1. create your new “restartScript.bat”, launch it then close it (and the “Miner Window”) to make the antivirus aware of that brand new .bat
2. go to your antivirus “File rating” section and in “Unrecognized Files” sort them by date to find your “restartScript.bat” at the top
3. right click it and “Add to > Trusted Files”
4. relaunch your “restartScript.bat” then authorize internet access (use runforseconds=10 to test if it kills “Miner Window” before making a new one)
5. set back your runforseconds to a few hours and you are done :)
sorry for extra detailed explanations but it might help some :p
i just had my well deserved “SUCCESS”
loszhor
July 30th, 2014 at 10:37
Thank you SO MUCH for this. My miners loss efficiency after about half an hour to an hour and I’ve been going crazy attempting do something like this without having to rely on extra API programs. Thanks again!
eugen
March 13th, 2017 at 10:02
this not working,
the batch file shut down an he tries to open ccminer.exe –> open and close quickly. nothing happens
john
July 22nd, 2017 at 03:13
how can i do on ccminer ? can i have some example ? thank you guys
john
July 22nd, 2017 at 17:05
i’ve made it
Harvick M.
August 19th, 2017 at 16:14
Hi, thanks for made it, but how to setup for Linux OS on Ubuntu, please tell me …
Aurion Kinetix
October 22nd, 2017 at 09:20
Gday! Thanks for the script. Its god sent!! Never again it freezes over! I’ve used it successfully using ccminer.
All you need to do is change set executable to ‘ccminer-x64.exe’
Also change set commandline parameters to copy from your original mining bat file after
“-a ALGOyouaremining -o stratum+tcp://whateverthepoolURL.com:portnumber -u yourusername.workername -p yourworkerpassword –cpu-priority 2 -i 21”
LC
October 26th, 2017 at 13:42
Is there any way to modify this script to also restart whenever the ‘stratum_recv_line failed’ error is received? My ccminer stops mining whenever I get this error.
Cryptiq
November 12th, 2017 at 01:44
Hi, taskkill is not killing off ccminer for me, so I end up with multiple miners running.
ERROR: Invalid argument/option – ‘ccminer-x64.exe’
Omar
December 23rd, 2017 at 11:23
How to use this and change the variables with nicehash miner? it happens that it crash and not autorestart. Thanks in advance !
Novicracker
May 9th, 2018 at 16:31
I think the question is not how to add in the AMD command line parameters.
setx GPU_FORCE_64BIT_PTR=1
setx GPU_USE_SYNC_OBJECTS=1
setx GPU_MAX_ALLOC_PERCENT=100
setx GPU_SINGLE_ALLOC_PERCENT=100
setx GPU_MAX_HEAP_SIZE=100
or alternatively how to have this script execute the batch files and still kill the miner windows?
Jexter
April 10th, 2021 at 23:22
Your genius admin, you definitely get rid of my headache. Thank you! I really appreciate your batch script.
emilio
May 9th, 2021 at 13:42
hello everyone, is it possible to modify the script so that the miner does a “control c” after 3600 seconds
Alexander
July 12th, 2021 at 20:22
This isnt working for me. It starts my mining software, but if the software stops it just keeps counting down anyway for the remainder of the 4 hours. Also, I tried testing it by closing the miner and then “pressing any button to continue” which it restarted the mining software, but now the counter doesnt count down for the next iteration.