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
    5 More HTML5 APIs You Didn’t Know Existed

    The HTML5 revolution has provided us some awesome JavaScript and HTML APIs.  Some are APIs we knew we've needed for years, others are cutting edge mobile and desktop helpers.  Regardless of API strength or purpose, anything to help us better do our job is a...

  • By
    Page Visibility API

    One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?

Incredible Demos

  • By
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

  • By
    Create a Trailing Mouse Cursor Effect Using MooTools

    Remember the old days of DHTML and effects that were an achievement to create but had absolutely no value? Well, a trailing mouse cursor script is sorta like that. And I'm sorta the type of guy that creates effects just because I can.

Discussion

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