How to Restart a BAT file on Windows at an Interval
I recently wrote a .bat
script on Windows to mine Ethereum when I'm not using my gaming PC to frag noobs. I have a friend who also tries to mine cryptocurrencies but their machines have AMD processors; every once in a while, the processor and the mining executable start fighting and all mining comes to a halt.
Having the mining .exe
stop work but not kill the process is a really frustrating problem. I thought it was a Windows sleep/hibernation issue but the solution I wrote about in that post didn't fix the problem. I went with the next best solution: killing and restarting the process after a given amount of time:
:loop start PhoenixMiner.exe -pool us1.ethermine.org:4444 -pool2 us1.ethermine.org:4444 -wal WALLET_ADDRESS -proto 3 echo "-------------------------------MINER STARTED" timeout /t 3600 >null echo "-------------------------------MINER TERMINATED, RESTARTING" taskkill /f /im "PhoenixMiner.exe" > null goto loop
This script kills the process and restarts it after an hour, regardless of if mining is running smoothly or has quit. This obviously isn't a perfect solution; a better answer would be to create a script to listen for an error and restart the process immediately. I will contend it's a workable solution so that mining isn't down for an entire night!