How to Restart a BAT file on Windows at an Interval

By  on  

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!

Recent Features

  • By
    Creating Scrolling Parallax Effects with CSS

    Introduction For quite a long time now websites with the so called "parallax" effect have been really popular. In case you have not heard of this effect, it basically includes different layers of images that are moving in different directions or with different speed. This leads to a...

  • By
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

Incredible Demos

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!